Skip to content

Commit

Permalink
fix(zoom): fix scale origin when document is scrolled
Browse files Browse the repository at this point in the history
fixes #6950
fixes #6955
  • Loading branch information
nolimits4web committed Aug 30, 2023
1 parent 106a3d7 commit 2cf3fc2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/zoom/zoom.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ export default function Zoom({ swiper, extendParams, on, emit }) {
if (evCache.length < 2) return { x: null, y: null };
const box = gesture.imageEl.getBoundingClientRect();
return [
(evCache[0].pageX + (evCache[1].pageX - evCache[0].pageX) / 2 - box.x) / currentScale,
(evCache[0].pageX + (evCache[1].pageX - evCache[0].pageX) / 2 - box.x - window.scrollX) /
currentScale,

(evCache[0].pageY + (evCache[1].pageY - evCache[0].pageY) / 2 - box.y) / currentScale,
(evCache[0].pageY + (evCache[1].pageY - evCache[0].pageY) / 2 - box.y - window.scrollY) /
currentScale,
];
}

Expand Down

0 comments on commit 2cf3fc2

Please sign in to comment.