Rename zoom anchor variables for clarity
Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
parent
875b46bacb
commit
9e0720a6c4
1 changed files with 12 additions and 12 deletions
|
@ -160,11 +160,11 @@ export default class ImageView extends React.Component<IProps, IState> {
|
|||
});
|
||||
};
|
||||
|
||||
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<IProps, IState> {
|
|||
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<IProps, IState> {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue