Skip to content

Keep image position stable at minimum zoom - #233

Merged
infeng merged 1 commit into
masterfrom
maintenance/week5-min-scale-position-95
Sep 1, 2026
Merged

Keep image position stable at minimum zoom#233
infeng merged 1 commit into
masterfrom
maintenance/week5-min-scale-position-95

Conversation

@infeng

@infeng infeng commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Reproduction

When wheel zoom reaches minScale, another zoom-out keeps the scale clamped but still changes translateX and translateY. The regression test reproduces the horizontal drift from 436.9px to 411.8px at a 0.95 minimum.

Root cause

The scale was clamped before rendering, but position updates still used the requested zoomSpeed rather than the scale delta that was actually applied.

Fix

  • Calculate translation from the effective scale delta after min/max clamping.
  • Add regression coverage for repeated off-center wheel zoom at minScale.

Verification

  • npm run verify
  • 42 Jest tests passed
  • Chrome 149 demo check: after reaching the default 0.1 minimum, an extra wheel zoom left the complete image transform unchanged
  • Public npm registry scan passed

Fixes #95

@infeng
infeng merged commit a936ccd into master Sep 1, 2026
2 checks passed
@infeng
infeng deleted the maintenance/week5-min-scale-position-95 branch September 1, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

到达最小缩放时, 再执行缩小操作, 图片不会平移, translateY, translateX 应该不变才对

1 participant