From f76063d57c1bd32c1d552af2f82a3ee4d72999ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Mon, 13 Jul 2020 12:51:38 +0200 Subject: [PATCH] fix the mousedown-wheel-translate issue (see comment https://github.com/d3/d3-zoom/issues/211#issuecomment-657487549) --- src/zoom.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/zoom.js b/src/zoom.js index b3c5d194..46a96cbf 100644 --- a/src/zoom.js +++ b/src/zoom.js @@ -284,7 +284,7 @@ export default function() { dragDisable(event.view); nopropagation(event); - g.mouse = [p, this.__zoom.invert(p)]; + g.prev = p; interrupt(this); g.start(); @@ -294,8 +294,10 @@ export default function() { var dx = event.clientX - x0, dy = event.clientY - y0; g.moved = dx * dx + dy * dy > clickDistance2; } + var p = pointer(event, currentTarget); g.event(event) - .zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = pointer(event, currentTarget), g.mouse[1]), g.extent, translateExtent)); + .zoom("mouse", constrain(translate(g.that.__zoom, p, g.that.__zoom.invert(g.prev)), g.extent, translateExtent)); + g.prev = p; } function mouseupped(event) {