performDoubleTapUp(pivotX, pivotY) { console.log('performDoubleTapUp...pivot=' + pivotX + ', ' + pivotY); let curScale = this.state.scale; //控制每次双击放大的倍数 let scaleBy = 1;
let rect = transformedRect(this.transformedContentRect(), new Transform( scaleBy, 0, 0, { x: pivotX, y: pivotY } ));
rect = transformedRect(rect, new Transform(1, this.viewPortRect().centerX() - pivotX, this.viewPortRect().centerY() - pivotY)); rect = alignedRect(rect, this.viewPortRect());
//控制上下边界 if (rect.top > viewPortRect.top) { dy = viewPortRect.top - rect.top; } elseif (Math.abs(rect.bottom) > 1000) { dy = 340; }
return rect.copy().offset(dx, dy); }
控制界面展示中心:TransformUtils.js-> fitCenterRect()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
exportfunctionfitCenterRect(contentAspectRatio, containerRect:Rect) { let w = containerRect.width(); let h = containerRect.height(); let viewAspectRatio = w / h;
if (contentAspectRatio > viewAspectRatio) { h = w / contentAspectRatio; } else { w = h * contentAspectRatio; }
//控制新界面的布局中心点 returnnew Rect( containerRect.centerX() - w / 2, containerRect.centerY() - h / 2, containerRect.centerX() + w / 2, containerRect.centerY() + h / 2 ); }