Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix panning of zoomed images
Signed-off-by: Dariusz Olszewski <[email protected]>
  • Loading branch information
starypatyk authored and skjnldsv committed Aug 15, 2023
commit a33d766a4d2000092cd1d596eea715a9b0f08304
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
}"
:src="data"
:style="{
marginTop: shiftY + 'px',
marginLeft: shiftX + 'px',
marginTop: (shiftY * 2) + 'px',
marginLeft: (shiftX * 2) + 'px',
maxHeight: zoomRatio * 100 + '%',
maxWidth: zoomRatio * 100 + '%',
}"
Expand Down Expand Up @@ -240,7 +240,7 @@ export default {
const growY = this.zoomHeight - this.height

this.shiftX = Math.min(Math.max(moveX, -growX / 2), growX / 2)
this.shiftY = Math.min(Math.max(moveY, -growY / 2), growX / 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, that looks like a nice typo! Can't believe that hasn't been caught in all those years

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key issue was incorrect calculation of top/left margins. I must admit that I am not fluent enough in CSS to fully understand why the shift must be multiplied by 2 to get the margins correct. But observations of the calculated box model in dev tools and testing confirmed this is the case. 😇

this.shiftY = Math.min(Math.max(moveY, -growY / 2), growY / 2)
this.dragX = pageX
this.dragY = pageY
}
Expand Down