|
1261 | 1261 | x: 0, |
1262 | 1262 | y: 0, |
1263 | 1263 | k: 1 |
1264 | | - }, 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; |
| 1264 | + }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, zooming = 0, 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; |
1265 | 1265 | function zoom(g) { |
1266 | 1266 | g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); |
1267 | 1267 | } |
|
1287 | 1287 | }; |
1288 | 1288 | zoomed(dispatch); |
1289 | 1289 | }; |
| 1290 | + }).each("interrupt.zoom", function() { |
| 1291 | + zoomended(dispatch); |
1290 | 1292 | }).each("end.zoom", function() { |
1291 | 1293 | zoomended(dispatch); |
1292 | 1294 | }); |
|
1378 | 1380 | }).map(y0.invert)); |
1379 | 1381 | } |
1380 | 1382 | function zoomstarted(dispatch) { |
1381 | | - dispatch({ |
| 1383 | + if (!zooming++) dispatch({ |
1382 | 1384 | type: "zoomstart" |
1383 | 1385 | }); |
1384 | 1386 | } |
|
1391 | 1393 | }); |
1392 | 1394 | } |
1393 | 1395 | function zoomended(dispatch) { |
1394 | | - dispatch({ |
| 1396 | + if (!--zooming) dispatch({ |
1395 | 1397 | type: "zoomend" |
1396 | 1398 | }); |
1397 | 1399 | } |
|
8593 | 8595 | } else { |
8594 | 8596 | d3_selection_each(this, function(node) { |
8595 | 8597 | var transition = node[ns][id]; |
8596 | | - (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener); |
| 8598 | + (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener); |
8597 | 8599 | }); |
8598 | 8600 | } |
8599 | 8601 | return this; |
|
8642 | 8644 | if (delay <= elapsed) return start(elapsed - delay); |
8643 | 8645 | timer.c = start; |
8644 | 8646 | function start(elapsed) { |
8645 | | - if (lock.active > id) return stop(); |
| 8647 | + if (lock.active > id) return stop(false); |
8646 | 8648 | lock.active = id; |
8647 | 8649 | transition.event && transition.event.start.call(node, d, i); |
8648 | 8650 | transition.tween.forEach(function(key, value) { |
|
8656 | 8658 | }, 0, time); |
8657 | 8659 | } |
8658 | 8660 | function tick(elapsed) { |
8659 | | - if (lock.active !== id) return stop(); |
| 8661 | + if (lock.active !== id) return stop(false); |
8660 | 8662 | var t = elapsed / duration, e = ease(t), n = tweened.length; |
8661 | 8663 | while (n > 0) { |
8662 | 8664 | tweened[--n].call(node, e); |
8663 | 8665 | } |
8664 | | - if (t >= 1) { |
8665 | | - transition.event && transition.event.end.call(node, d, i); |
8666 | | - return stop(); |
8667 | | - } |
| 8666 | + if (t >= 1) return stop(true); |
8668 | 8667 | } |
8669 | | - function stop() { |
| 8668 | + function stop(end) { |
| 8669 | + if (transition.event) transition.event[end ? "end" : "interrupt"].call(node, d, i); |
8670 | 8670 | if (--lock.count) delete lock[id]; else delete node[namespace]; |
8671 | 8671 | return 1; |
8672 | 8672 | } |
|
0 commit comments