Skip to content

Commit 8a0fe7f

Browse files
committed
Merge branch '3.5.1'
2 parents 737a991 + d316211 commit 8a0fe7f

12 files changed

Lines changed: 189 additions & 104 deletions

File tree

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.5.0",
3+
"version": "3.5.1",
44
"main": "d3.js",
55
"scripts": [
66
"d3.js"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"animation",
1111
"canvas"
1212
],
13-
"version": "3.5.0",
13+
"version": "3.5.1",
1414
"main": "d3.js",
1515
"scripts": [
1616
"d3.js"

d3.js

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!function() {
22
var d3 = {
3-
version: "3.5.0"
3+
version: "3.5.1"
44
};
55
if (!Date.now) Date.now = function() {
66
return +new Date();
@@ -989,33 +989,6 @@
989989
return node;
990990
};
991991
}
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-
}
1019992
d3.select = function(node) {
1020993
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
1021994
group.parentNode = d3_documentElement;
@@ -1425,7 +1398,7 @@
14251398
}
14261399
function mousedowned() {
14271400
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);
14291402
zoomstarted(dispatch);
14301403
function moved() {
14311404
dragged = 1;
@@ -1474,7 +1447,7 @@
14741447
}
14751448
function moved() {
14761449
var touches = d3.touches(that), p0, l0, p1, l1;
1477-
d3_selection_interrupt(that);
1450+
d3_selection_interrupt.call(that);
14781451
for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
14791452
p1 = touches[i];
14801453
if (l1 = locations0[p1.identifier]) {
@@ -1511,7 +1484,7 @@
15111484
function mousewheeled() {
15121485
var dispatch = event.of(this, arguments);
15131486
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);
15151488
mousewheelTimer = setTimeout(function() {
15161489
mousewheelTimer = null;
15171490
zoomended(dispatch);
@@ -8553,9 +8526,43 @@
85538526
});
85548527
d3.svg.symbolTypes = d3_svg_symbols.keys();
85558528
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) {
85578564
d3_subclass(groups, d3_transitionPrototype);
8558-
groups.namespace = namespace;
8565+
groups.namespace = ns;
85598566
groups.id = id;
85608567
return groups;
85618568
}
@@ -8564,8 +8571,8 @@
85648571
d3_transitionPrototype.empty = d3_selectionPrototype.empty;
85658572
d3_transitionPrototype.node = d3_selectionPrototype.node;
85668573
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);
85698576
};
85708577
d3.transition.prototype = d3_transitionPrototype;
85718578
d3_transitionPrototype.select = function(selector) {
@@ -8758,13 +8765,16 @@
87588765
var id = this.id, ns = this.namespace;
87598766
if (arguments.length < 2) {
87608767
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+
}
87688778
} else {
87698779
d3_selection_each(this, function(node) {
87708780
var transition = node[ns][id];
@@ -8795,8 +8805,8 @@
87958805
function d3_transitionNamespace(name) {
87968806
return name == null ? "__transition__" : "__transition_" + name + "__";
87978807
}
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] = {
88008810
active: 0,
88018811
count: 0
88028812
}), transition = lock[id];
@@ -8807,21 +8817,28 @@
88078817
time: time,
88088818
delay: inherit.delay,
88098819
duration: inherit.duration,
8810-
ease: inherit.ease
8820+
ease: inherit.ease,
8821+
index: i
88118822
};
88128823
inherit = null;
88138824
++lock.count;
88148825
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 = [];
88168827
timer.t = delay + time;
88178828
if (delay <= elapsed) return start(elapsed - delay);
88188829
timer.c = start;
88198830
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+
}
88218838
lock.active = id;
8822-
transition.event && transition.event.start.call(node, d, i);
8839+
transition.event && transition.event.start.call(node, node.__data__, i);
88238840
transition.tween.forEach(function(key, value) {
8824-
if (value = value.call(node, d, i)) {
8841+
if (value = value.call(node, node.__data__, i)) {
88258842
tweened.push(value);
88268843
}
88278844
});
@@ -8833,16 +8850,18 @@
88338850
}, 0, time);
88348851
}
88358852
function tick(elapsed) {
8836-
if (lock.active !== id) return stop(false);
8853+
if (lock.active !== id) return 1;
88378854
var t = elapsed / duration, e = ease(t), n = tweened.length;
88388855
while (n > 0) {
88398856
tweened[--n].call(node, e);
88408857
}
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+
}
88428862
}
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];
88468865
return 1;
88478866
}
88488867
}, 0, time);

d3.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.5.0",
3+
"version": "3.5.1",
44
"description": "A JavaScript visualization library for HTML and SVG.",
55
"keywords": [
66
"dom",

src/behavior/zoom.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ d3.behavior.zoom = function() {
187187
location0 = location(d3.mouse(that)),
188188
dragRestore = d3_event_dragSuppress();
189189

190-
d3_selection_interrupt(that);
190+
d3_selection_interrupt.call(that);
191191
zoomstarted(dispatch);
192192

193193
function moved() {
@@ -270,7 +270,7 @@ d3.behavior.zoom = function() {
270270
p0, l0,
271271
p1, l1;
272272

273-
d3_selection_interrupt(that);
273+
d3_selection_interrupt.call(that);
274274

275275
for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
276276
p1 = touches[i];
@@ -318,7 +318,7 @@ d3.behavior.zoom = function() {
318318
function mousewheeled() {
319319
var dispatch = event.of(this, arguments);
320320
if (mousewheelTimer) clearTimeout(mousewheelTimer);
321-
else translate0 = location(center0 = center || d3.mouse(this)), d3_selection_interrupt(this), zoomstarted(dispatch);
321+
else translate0 = location(center0 = center || d3.mouse(this)), d3_selection_interrupt.call(this), zoomstarted(dispatch);
322322
mousewheelTimer = setTimeout(function() { mousewheelTimer = null; zoomended(dispatch); }, 50);
323323
d3_eventPreventDefault();
324324
scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);

src/selection/interrupt.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,24 @@ import "selection";
33

44
// TODO Interrupt transitions for all namespaces?
55
d3_selectionPrototype.interrupt = function(name) {
6-
var ns = d3_transitionNamespace(name);
7-
return this.each(function() {
8-
var lock = this[ns];
9-
if (lock) ++lock.active;
10-
});
6+
return this.each(name == null
7+
? d3_selection_interrupt
8+
: d3_selection_interruptNS(d3_transitionNamespace(name)));
119
};
1210

13-
function d3_selection_interrupt(that) {
14-
var lock = that.__transition__;
15-
if (lock) ++lock.active;
11+
var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());
12+
13+
function d3_selection_interruptNS(ns) {
14+
return function() {
15+
var lock, active;
16+
if ((lock = this[ns]) && (active = lock[lock.active])) {
17+
if (--lock.count) {
18+
delete lock[lock.active];
19+
lock.active += .5;
20+
} else {
21+
delete this[ns];
22+
}
23+
active.event && active.event.interrupt.call(this, this.__data__, active.index);
24+
}
25+
};
1626
}

src/selection/selection.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ import "node";
5050
import "size";
5151
import "enter";
5252

53-
import "transition";
54-
import "interrupt";
55-
5653
// TODO fast singleton implementation?
5754
d3.select = function(node) {
5855
var group = [typeof node === "string" ? d3_select(node, d3_document) : node];

src/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
!function(){
2-
var d3 = {version: "3.5.0"}; // semver
2+
var d3 = {version: "3.5.1"}; // semver

src/transition/each.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ d3_transitionPrototype.each = function(type, listener) {
66
if (arguments.length < 2) {
77
var inherit = d3_transitionInherit,
88
inheritId = d3_transitionInheritId;
9-
d3_transitionInheritId = id;
10-
d3_selection_each(this, function(node, i, j) {
11-
d3_transitionInherit = node[ns][id];
12-
type.call(node, node.__data__, i, j);
13-
});
14-
d3_transitionInherit = inherit;
15-
d3_transitionInheritId = inheritId;
9+
try {
10+
d3_transitionInheritId = id;
11+
d3_selection_each(this, function(node, i, j) {
12+
d3_transitionInherit = node[ns][id];
13+
type.call(node, node.__data__, i, j);
14+
});
15+
} finally {
16+
d3_transitionInherit = inherit;
17+
d3_transitionInheritId = inheritId;
18+
}
1619
} else {
1720
d3_selection_each(this, function(node) {
1821
var transition = node[ns][id];

0 commit comments

Comments
 (0)