Skip to content

Commit 1177d1d

Browse files
committed
Merge branch '3.2.1'
2 parents 84f4a62 + 7287f35 commit 1177d1d

20 files changed

Lines changed: 85 additions & 38 deletions

component.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.2.0",
3+
"version": "3.2.1",
44
"main": "index-browserify.js",
55
"scripts": [
66
"index-browserify.js",

d3.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
d3 = function() {
22
var d3 = {
3-
version: "3.2.0"
3+
version: "3.2.1"
44
};
55
if (!Date.now) Date.now = function() {
66
return +new Date();
@@ -23,35 +23,35 @@ d3 = function() {
2323
d3.min = function(array, f) {
2424
var i = -1, n = array.length, a, b;
2525
if (arguments.length === 1) {
26-
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
26+
while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
2727
while (++i < n) if ((b = array[i]) != null && a > b) a = b;
2828
} else {
29-
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
29+
while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
3030
while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
3131
}
3232
return a;
3333
};
3434
d3.max = function(array, f) {
3535
var i = -1, n = array.length, a, b;
3636
if (arguments.length === 1) {
37-
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
37+
while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
3838
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
3939
} else {
40-
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
40+
while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
4141
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
4242
}
4343
return a;
4444
};
4545
d3.extent = function(array, f) {
4646
var i = -1, n = array.length, a, b, c;
4747
if (arguments.length === 1) {
48-
while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
48+
while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined;
4949
while (++i < n) if ((b = array[i]) != null) {
5050
if (a > b) a = b;
5151
if (c < b) c = b;
5252
}
5353
} else {
54-
while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
54+
while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
5555
while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
5656
if (a > b) a = b;
5757
if (c < b) c = b;
@@ -1136,7 +1136,7 @@ d3 = function() {
11361136
};
11371137
var d3_selectionRoot = d3.select(d3_documentElement);
11381138
d3.behavior.zoom = function() {
1139-
var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
1139+
var translate = [ 0, 0 ], translate0, scale = 1, distance0, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
11401140
function zoom() {
11411141
this.on("mousedown.zoom", mousedown).on("mousemove.zoom", mousemove).on(d3_behavior_zoomWheel + ".zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart);
11421142
}
@@ -1237,6 +1237,7 @@ d3 = function() {
12371237
var touches = d3.touches(this), now = Date.now();
12381238
scale0 = scale;
12391239
translate0 = {};
1240+
distance0 = 0;
12401241
touches.forEach(function(t) {
12411242
translate0[t.identifier] = location(t);
12421243
});
@@ -1248,15 +1249,22 @@ d3 = function() {
12481249
dispatch(event.of(this, arguments));
12491250
}
12501251
touchtime = now;
1252+
} else if (touches.length > 1) {
1253+
var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
1254+
distance0 = dx * dx + dy * dy;
12511255
}
12521256
}
12531257
function touchmove() {
12541258
var touches = d3.touches(this), p0 = touches[0], l0 = translate0[p0.identifier];
12551259
if (p1 = touches[1]) {
1256-
var p1, l1 = translate0[p1.identifier];
1260+
var p1, l1 = translate0[p1.identifier], scale1 = d3.event.scale;
1261+
if (scale1 == null) {
1262+
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
1263+
scale1 = distance0 && Math.sqrt(distance1 / distance0);
1264+
}
12571265
p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
12581266
l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
1259-
scaleTo(d3.event.scale * scale0);
1267+
scaleTo(scale1 * scale0);
12601268
}
12611269
translateTo(p0, l0);
12621270
touchtime = null;
@@ -7020,8 +7028,7 @@ d3 = function() {
70207028
return scale;
70217029
}
70227030
function scale(x) {
7023-
if (isNaN(x = +x)) return NaN;
7024-
return range[d3.bisect(thresholds, x)];
7031+
if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];
70257032
}
70267033
scale.domain = function(x) {
70277034
if (!arguments.length) return domain;
@@ -7082,7 +7089,7 @@ d3 = function() {
70827089
};
70837090
function d3_scale_threshold(domain, range) {
70847091
function scale(x) {
7085-
return range[d3.bisect(domain, x)];
7092+
if (x <= x) return range[d3.bisect(domain, x)];
70867093
}
70877094
scale.domain = function(_) {
70887095
if (!arguments.length) return domain;
@@ -7475,7 +7482,7 @@ d3 = function() {
74757482
subnodes = selector.call(node, node.__data__, i);
74767483
subgroups.push(subgroup = []);
74777484
for (var k = -1, o = subnodes.length; ++k < o; ) {
7478-
d3_transitionNode(subnode = subnodes[k], k, id, transition);
7485+
if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition);
74797486
subgroup.push(subnode);
74807487
}
74817488
}
@@ -8047,8 +8054,8 @@ d3 = function() {
80478054
return brush;
80488055
};
80498056
brush.clamp = function(z) {
8050-
if (!arguments.length) return x && y ? clamp : clamp[+!x];
8051-
if (x && y) clamp = [ !!z[0], !!z[1] ]; else clamp[+!x] = !!z;
8057+
if (!arguments.length) return x && y ? clamp : x || y ? clamp[+!x] : null;
8058+
if (x && y) clamp = [ !!z[0], !!z[1] ]; else if (x || y) clamp[+!x] = !!z;
80528059
return brush;
80538060
};
80548061
brush.extent = function(z) {

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.2.0",
3+
"version": "3.2.1",
44
"description": "A small, free JavaScript library for manipulating documents based on data.",
55
"keywords": [
66
"dom",

src/arrays/extent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ d3.extent = function(array, f) {
55
b,
66
c;
77
if (arguments.length === 1) {
8-
while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
8+
while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined;
99
while (++i < n) if ((b = array[i]) != null) {
1010
if (a > b) a = b;
1111
if (c < b) c = b;
1212
}
1313
} else {
14-
while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
14+
while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
1515
while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
1616
if (a > b) a = b;
1717
if (c < b) c = b;

src/arrays/max.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ d3.max = function(array, f) {
44
a,
55
b;
66
if (arguments.length === 1) {
7-
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
7+
while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
88
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
99
} else {
10-
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
10+
while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
1111
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
1212
}
1313
return a;

src/arrays/min.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ d3.min = function(array, f) {
44
a,
55
b;
66
if (arguments.length === 1) {
7-
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
7+
while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
88
while (++i < n) if ((b = array[i]) != null && a > b) a = b;
99
} else {
10-
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
10+
while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
1111
while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
1212
}
1313
return a;

src/behavior/zoom.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ d3.behavior.zoom = function() {
1111
var translate = [0, 0],
1212
translate0, // translate when we started zooming (to avoid drift)
1313
scale = 1,
14+
distance0, // distance² between initial touches
1415
scale0, // scale when we started touching
1516
scaleExtent = d3_behavior_zoomInfinity,
1617
event = d3_eventDispatch(zoom, "zoom"),
@@ -144,6 +145,7 @@ d3.behavior.zoom = function() {
144145

145146
scale0 = scale;
146147
translate0 = {};
148+
distance0 = 0;
147149
touches.forEach(function(t) { translate0[t.identifier] = location(t); });
148150

149151
if (touches.length === 1) {
@@ -154,6 +156,10 @@ d3.behavior.zoom = function() {
154156
dispatch(event.of(this, arguments));
155157
}
156158
touchtime = now;
159+
} else if (touches.length > 1) {
160+
var p = touches[0], q = touches[1],
161+
dx = p[0] - q[0], dy = p[1] - q[1];
162+
distance0 = dx * dx + dy * dy;
157163
}
158164
}
159165

@@ -162,10 +168,15 @@ d3.behavior.zoom = function() {
162168
p0 = touches[0],
163169
l0 = translate0[p0.identifier];
164170
if (p1 = touches[1]) {
165-
var p1, l1 = translate0[p1.identifier];
171+
var p1, l1 = translate0[p1.identifier],
172+
scale1 = d3.event.scale;
173+
if (scale1 == null) {
174+
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
175+
scale1 = distance0 && Math.sqrt(distance1 / distance0);
176+
}
166177
p0 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
167178
l0 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
168-
scaleTo(d3.event.scale * scale0);
179+
scaleTo(scale1 * scale0);
169180
}
170181
translateTo(p0, l0);
171182
touchtime = null;

src/scale/quantile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ function d3_scale_quantile(domain, range) {
1919
}
2020

2121
function scale(x) {
22-
if (isNaN(x = +x)) return NaN;
23-
return range[d3.bisect(thresholds, x)];
22+
if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];
2423
}
2524

2625
scale.domain = function(x) {

src/scale/threshold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ d3.scale.threshold = function() {
88
function d3_scale_threshold(domain, range) {
99

1010
function scale(x) {
11-
return range[d3.bisect(domain, x)];
11+
if (x <= x) return range[d3.bisect(domain, x)];
1212
}
1313

1414
scale.domain = function(_) {

0 commit comments

Comments
 (0)