Skip to content

Commit

Permalink
Fix: If "opts.focal" - calculate coordinates taking into account the …
Browse files Browse the repository at this point in the history
…planned Scale, and not just the calculated Scale (jquery.panzoom.js)

I created a PR in the author's repository, but there is no feedback yet.
timmywil/panzoom#669
  • Loading branch information
IgorA100 authored Jun 17, 2024
1 parent 70c5d87 commit 54d363b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@
if (!opts.force && opts.disableZoom) {
return;
}
const toScalePlanned = toScale;
toScale = result.scale;
var toX = x;
var toY = y;
Expand All @@ -581,8 +582,8 @@
// plus the current translation after the scale
// neutralized to no scale (as the transform scale will apply to the translation)
var focal = opts.focal;
toX = (focal.x / toScale - focal.x / scale + x * toScale) / toScale;
toY = (focal.y / toScale - focal.y / scale + y * toScale) / toScale;
toX = (focal.x / toScale - focal.x / scale + x * toScalePlanned) / toScalePlanned;
toY = (focal.y / toScale - focal.y / scale + y * toScalePlanned) / toScalePlanned;
}
var panResult = constrainXY(toX, toY, toScale, { relative: false, force: true });
x = panResult.x;
Expand Down

0 comments on commit 54d363b

Please sign in to comment.