|
1 | 1 | !function() { |
2 | 2 | var d3 = { |
3 | | - version: "3.5.0" |
| 3 | + version: "3.5.1" |
4 | 4 | }; |
5 | 5 | if (!Date.now) Date.now = function() { |
6 | 6 | return +new Date(); |
|
989 | 989 | return node; |
990 | 990 | }; |
991 | 991 | } |
992 | | - d3_selectionPrototype.transition = function(name) { |
993 | | - var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { |
994 | | - time: Date.now(), |
995 | | - ease: d3_ease_cubicInOut, |
996 | | - delay: 0, |
997 | | - duration: 250 |
998 | | - }; |
999 | | - for (var j = -1, m = this.length; ++j < m; ) { |
1000 | | - subgroups.push(subgroup = []); |
1001 | | - for (var group = this[j], i = -1, n = group.length; ++i < n; ) { |
1002 | | - if (node = group[i]) d3_transitionNode(node, i, ns, id, transition); |
1003 | | - subgroup.push(node); |
1004 | | - } |
1005 | | - } |
1006 | | - return d3_transition(subgroups, ns, id); |
1007 | | - }; |
1008 | | - d3_selectionPrototype.interrupt = function(name) { |
1009 | | - var ns = d3_transitionNamespace(name); |
1010 | | - return this.each(function() { |
1011 | | - var lock = this[ns]; |
1012 | | - if (lock) ++lock.active; |
1013 | | - }); |
1014 | | - }; |
1015 | | - function d3_selection_interrupt(that) { |
1016 | | - var lock = that.__transition__; |
1017 | | - if (lock) ++lock.active; |
1018 | | - } |
1019 | 992 | d3.select = function(node) { |
1020 | 993 | var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ]; |
1021 | 994 | group.parentNode = d3_documentElement; |
|
1425 | 1398 | } |
1426 | 1399 | function mousedowned() { |
1427 | 1400 | var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(); |
1428 | | - d3_selection_interrupt(that); |
| 1401 | + d3_selection_interrupt.call(that); |
1429 | 1402 | zoomstarted(dispatch); |
1430 | 1403 | function moved() { |
1431 | 1404 | dragged = 1; |
|
1474 | 1447 | } |
1475 | 1448 | function moved() { |
1476 | 1449 | var touches = d3.touches(that), p0, l0, p1, l1; |
1477 | | - d3_selection_interrupt(that); |
| 1450 | + d3_selection_interrupt.call(that); |
1478 | 1451 | for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { |
1479 | 1452 | p1 = touches[i]; |
1480 | 1453 | if (l1 = locations0[p1.identifier]) { |
|
1511 | 1484 | function mousewheeled() { |
1512 | 1485 | var dispatch = event.of(this, arguments); |
1513 | 1486 | if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)), |
1514 | | - d3_selection_interrupt(this), zoomstarted(dispatch); |
| 1487 | + d3_selection_interrupt.call(this), zoomstarted(dispatch); |
1515 | 1488 | mousewheelTimer = setTimeout(function() { |
1516 | 1489 | mousewheelTimer = null; |
1517 | 1490 | zoomended(dispatch); |
|
8553 | 8526 | }); |
8554 | 8527 | d3.svg.symbolTypes = d3_svg_symbols.keys(); |
8555 | 8528 | var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); |
8556 | | - function d3_transition(groups, namespace, id) { |
| 8529 | + d3_selectionPrototype.transition = function(name) { |
| 8530 | + var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { |
| 8531 | + time: Date.now(), |
| 8532 | + ease: d3_ease_cubicInOut, |
| 8533 | + delay: 0, |
| 8534 | + duration: 250 |
| 8535 | + }; |
| 8536 | + for (var j = -1, m = this.length; ++j < m; ) { |
| 8537 | + subgroups.push(subgroup = []); |
| 8538 | + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { |
| 8539 | + if (node = group[i]) d3_transitionNode(node, i, ns, id, transition); |
| 8540 | + subgroup.push(node); |
| 8541 | + } |
| 8542 | + } |
| 8543 | + return d3_transition(subgroups, ns, id); |
| 8544 | + }; |
| 8545 | + d3_selectionPrototype.interrupt = function(name) { |
| 8546 | + return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name))); |
| 8547 | + }; |
| 8548 | + var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); |
| 8549 | + function d3_selection_interruptNS(ns) { |
| 8550 | + return function() { |
| 8551 | + var lock, active; |
| 8552 | + if ((lock = this[ns]) && (active = lock[lock.active])) { |
| 8553 | + if (--lock.count) { |
| 8554 | + delete lock[lock.active]; |
| 8555 | + lock.active += .5; |
| 8556 | + } else { |
| 8557 | + delete this[ns]; |
| 8558 | + } |
| 8559 | + active.event && active.event.interrupt.call(this, this.__data__, active.index); |
| 8560 | + } |
| 8561 | + }; |
| 8562 | + } |
| 8563 | + function d3_transition(groups, ns, id) { |
8557 | 8564 | d3_subclass(groups, d3_transitionPrototype); |
8558 | | - groups.namespace = namespace; |
| 8565 | + groups.namespace = ns; |
8559 | 8566 | groups.id = id; |
8560 | 8567 | return groups; |
8561 | 8568 | } |
|
8564 | 8571 | d3_transitionPrototype.empty = d3_selectionPrototype.empty; |
8565 | 8572 | d3_transitionPrototype.node = d3_selectionPrototype.node; |
8566 | 8573 | d3_transitionPrototype.size = d3_selectionPrototype.size; |
8567 | | - d3.transition = function(selection) { |
8568 | | - return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); |
| 8574 | + d3.transition = function(selection, name) { |
| 8575 | + return arguments.length ? d3_transitionInheritId ? selection.transition(name) : selection : d3_selectionRoot.transition(name); |
8569 | 8576 | }; |
8570 | 8577 | d3.transition.prototype = d3_transitionPrototype; |
8571 | 8578 | d3_transitionPrototype.select = function(selector) { |
|
8758 | 8765 | var id = this.id, ns = this.namespace; |
8759 | 8766 | if (arguments.length < 2) { |
8760 | 8767 | var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; |
8761 | | - d3_transitionInheritId = id; |
8762 | | - d3_selection_each(this, function(node, i, j) { |
8763 | | - d3_transitionInherit = node[ns][id]; |
8764 | | - type.call(node, node.__data__, i, j); |
8765 | | - }); |
8766 | | - d3_transitionInherit = inherit; |
8767 | | - d3_transitionInheritId = inheritId; |
| 8768 | + try { |
| 8769 | + d3_transitionInheritId = id; |
| 8770 | + d3_selection_each(this, function(node, i, j) { |
| 8771 | + d3_transitionInherit = node[ns][id]; |
| 8772 | + type.call(node, node.__data__, i, j); |
| 8773 | + }); |
| 8774 | + } finally { |
| 8775 | + d3_transitionInherit = inherit; |
| 8776 | + d3_transitionInheritId = inheritId; |
| 8777 | + } |
8768 | 8778 | } else { |
8769 | 8779 | d3_selection_each(this, function(node) { |
8770 | 8780 | var transition = node[ns][id]; |
|
8795 | 8805 | function d3_transitionNamespace(name) { |
8796 | 8806 | return name == null ? "__transition__" : "__transition_" + name + "__"; |
8797 | 8807 | } |
8798 | | - function d3_transitionNode(node, i, namespace, id, inherit) { |
8799 | | - var lock = node[namespace] || (node[namespace] = { |
| 8808 | + function d3_transitionNode(node, i, ns, id, inherit) { |
| 8809 | + var lock = node[ns] || (node[ns] = { |
8800 | 8810 | active: 0, |
8801 | 8811 | count: 0 |
8802 | 8812 | }), transition = lock[id]; |
|
8807 | 8817 | time: time, |
8808 | 8818 | delay: inherit.delay, |
8809 | 8819 | duration: inherit.duration, |
8810 | | - ease: inherit.ease |
| 8820 | + ease: inherit.ease, |
| 8821 | + index: i |
8811 | 8822 | }; |
8812 | 8823 | inherit = null; |
8813 | 8824 | ++lock.count; |
8814 | 8825 | d3.timer(function(elapsed) { |
8815 | | - var d = node.__data__, delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = []; |
| 8826 | + var delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = []; |
8816 | 8827 | timer.t = delay + time; |
8817 | 8828 | if (delay <= elapsed) return start(elapsed - delay); |
8818 | 8829 | timer.c = start; |
8819 | 8830 | function start(elapsed) { |
8820 | | - if (lock.active > id) return stop(false); |
| 8831 | + if (lock.active > id) return stop(); |
| 8832 | + var active = lock[lock.active]; |
| 8833 | + if (active) { |
| 8834 | + --lock.count; |
| 8835 | + delete lock[lock.active]; |
| 8836 | + active.event && active.event.interrupt.call(node, node.__data__, active.index); |
| 8837 | + } |
8821 | 8838 | lock.active = id; |
8822 | | - transition.event && transition.event.start.call(node, d, i); |
| 8839 | + transition.event && transition.event.start.call(node, node.__data__, i); |
8823 | 8840 | transition.tween.forEach(function(key, value) { |
8824 | | - if (value = value.call(node, d, i)) { |
| 8841 | + if (value = value.call(node, node.__data__, i)) { |
8825 | 8842 | tweened.push(value); |
8826 | 8843 | } |
8827 | 8844 | }); |
|
8833 | 8850 | }, 0, time); |
8834 | 8851 | } |
8835 | 8852 | function tick(elapsed) { |
8836 | | - if (lock.active !== id) return stop(false); |
| 8853 | + if (lock.active !== id) return 1; |
8837 | 8854 | var t = elapsed / duration, e = ease(t), n = tweened.length; |
8838 | 8855 | while (n > 0) { |
8839 | 8856 | tweened[--n].call(node, e); |
8840 | 8857 | } |
8841 | | - if (t >= 1) return stop(true); |
| 8858 | + if (t >= 1) { |
| 8859 | + transition.event && transition.event.end.call(node, node.__data__, i); |
| 8860 | + return stop(); |
| 8861 | + } |
8842 | 8862 | } |
8843 | | - function stop(end) { |
8844 | | - if (transition.event) transition.event[end ? "end" : "interrupt"].call(node, d, i); |
8845 | | - if (--lock.count) delete lock[id]; else delete node[namespace]; |
| 8863 | + function stop() { |
| 8864 | + if (--lock.count) delete lock[id]; else delete node[ns]; |
8846 | 8865 | return 1; |
8847 | 8866 | } |
8848 | 8867 | }, 0, time); |
|
0 commit comments