Fix: If "opts.focal" - calculate coordinates taking into account the 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.
https://github.com/timmywil/panzoom/pull/669
pull/4082/head
IgorA100 2024-06-17 11:16:11 +03:00 committed by GitHub
parent 70c5d871d3
commit 54d363bf85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -573,6 +573,7 @@
if (!opts.force && opts.disableZoom) {
return;
}
const toScalePlanned = toScale;
toScale = result.scale;
var toX = x;
var toY = y;
@ -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;