diff --git a/src/components/views/elements/ImageView.tsx b/src/components/views/elements/ImageView.tsx index 4059277ea3..1979da5295 100644 --- a/src/components/views/elements/ImageView.tsx +++ b/src/components/views/elements/ImageView.tsx @@ -160,11 +160,11 @@ export default class ImageView extends React.Component { }); }; - private zoomDelta(delta: number, zoomX?: number, zoomY?: number) { - this.zoom(this.state.zoom + delta, zoomX, zoomY); + private zoomDelta(delta: number, anchorX?: number, anchorY?: number) { + this.zoom(this.state.zoom + delta, anchorX, anchorY); } - private zoom(zoomLevel: number, zoomX?: number, zoomY?: number) { + private zoom(zoomLevel: number, anchorX?: number, anchorY?: number) { const oldZoom = this.state.zoom; const newZoom = Math.min(zoomLevel, this.state.maxZoom); @@ -175,7 +175,7 @@ export default class ImageView extends React.Component { translationX: 0, translationY: 0, }); - } else if (typeof zoomX !== "number" && typeof zoomY !== "number") { + } else if (typeof anchorX !== "number" && typeof anchorY !== "number") { // Zoom relative to the center of the view this.setState({ zoom: newZoom, @@ -190,20 +190,20 @@ export default class ImageView extends React.Component { let offsetY; switch (((this.state.rotation % 360) + 360) % 360) { case 0: - offsetX = this.image.current.clientWidth / 2 - zoomX; - offsetY = this.image.current.clientHeight / 2 - zoomY; + offsetX = this.image.current.clientWidth / 2 - anchorX; + offsetY = this.image.current.clientHeight / 2 - anchorY; break; case 90: - offsetX = zoomY - this.image.current.clientHeight / 2; - offsetY = this.image.current.clientWidth / 2 - zoomX; + offsetX = anchorY - this.image.current.clientHeight / 2; + offsetY = this.image.current.clientWidth / 2 - anchorX; break; case 180: - offsetX = zoomX - this.image.current.clientWidth / 2; - offsetY = zoomY - this.image.current.clientHeight / 2; + offsetX = anchorX - this.image.current.clientWidth / 2; + offsetY = anchorY - this.image.current.clientHeight / 2; break; case 270: - offsetX = this.image.current.clientHeight / 2 - zoomY; - offsetY = zoomX - this.image.current.clientWidth / 2; + offsetX = this.image.current.clientHeight / 2 - anchorY; + offsetY = anchorX - this.image.current.clientWidth / 2; } // Apply the zoom and offset