|
1227 | 1227 | x: 0, |
1228 | 1228 | y: 0, |
1229 | 1229 | k: 1 |
1230 | | - }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; |
| 1230 | + }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; |
1231 | 1231 | function zoom(g) { |
1232 | | - g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); |
| 1232 | + g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); |
1233 | 1233 | } |
1234 | 1234 | zoom.event = function(g) { |
1235 | 1235 | g.each(function() { |
|
1371 | 1371 | zoomed(dispatch); |
1372 | 1372 | } |
1373 | 1373 | function ended() { |
1374 | | - subject.on(mousemove, d3_window === that ? mousewheelreset : null).on(mouseup, null); |
| 1374 | + subject.on(mousemove, null).on(mouseup, null); |
1375 | 1375 | dragRestore(dragged && d3.event.target === target); |
1376 | 1376 | zoomended(dispatch); |
1377 | 1377 | } |
|
1449 | 1449 | } |
1450 | 1450 | function mousewheeled() { |
1451 | 1451 | var dispatch = event.of(this, arguments); |
1452 | | - if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), |
1453 | | - zoomstarted(dispatch); |
| 1452 | + if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)), |
| 1453 | + d3_selection_interrupt.call(this), zoomstarted(dispatch); |
1454 | 1454 | mousewheelTimer = setTimeout(function() { |
1455 | 1455 | mousewheelTimer = null; |
1456 | 1456 | zoomended(dispatch); |
1457 | 1457 | }, 50); |
1458 | 1458 | d3_eventPreventDefault(); |
1459 | | - var point = center || d3.mouse(this); |
1460 | | - if (!translate0) translate0 = location(point); |
1461 | 1459 | scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); |
1462 | | - translateTo(point, translate0); |
| 1460 | + translateTo(center0, translate0); |
1463 | 1461 | zoomed(dispatch); |
1464 | 1462 | } |
1465 | | - function mousewheelreset() { |
1466 | | - translate0 = null; |
1467 | | - } |
1468 | 1463 | function dblclicked() { |
1469 | 1464 | var dispatch = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2; |
1470 | 1465 | zoomstarted(dispatch); |
|
0 commit comments