Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: If "opts.focal" - calculate coordinates taking into account the planned Scale, and not just the calculated Scale #669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/panzoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function Panzoom(
if (!opts.force && opts.disableZoom) {
return
}
const toScalePlanned = toScale
toScale = result.scale
let toX = x
let toY = y
Expand All @@ -323,8 +324,8 @@ function Panzoom(
// plus the current translation after the scale
// neutralized to no scale (as the transform scale will apply to the translation)
const 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
}
const panResult = constrainXY(toX, toY, toScale, { relative: false, force: true })
x = panResult.x
Expand Down