Skip to content

Commit

Permalink
Fix pinching position when the zoom level hits limit
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Feb 6, 2022
1 parent 185c6c5 commit 434665f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions view/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,10 @@ class DigitalJS {
}

instance.zoom(pinch_state.init_scale * ev.scale);
instance.pan({ x: pinch_state.init_dist.x * ev.scale + ev.center.x,
y: pinch_state.init_dist.y * ev.scale + ev.center.y });
// The zoom level may not be what we requested when it hits the limit
const scale = instance.getZoom() / pinch_state.init_scale;
instance.pan({ x: pinch_state.init_dist.x * scale + ev.center.x,
y: pinch_state.init_dist.y * scale + ev.center.y });
});
hammer.on('pinchcancel pinchend', () => {
pinch_state.enabled = false;
Expand Down

0 comments on commit 434665f

Please sign in to comment.