Commit abc9dbb0 authored by Jason Davies's avatar Jason Davies
Browse files

Use distance instead of d3.event.scale.

Unlike d3.event.scale, which is a single value provided by the browser
(usually an average based on the position of all touches), we can
compute separate distances for each zoom gesture and its target,
allowing multiple gestures to occur simultaneously.
parent 340b1675
......@@ -1397,11 +1397,7 @@ d3 = function() {
}
}
if (l1) {
var scale1 = d3.event.scale;
if (scale1 == null) {
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
scale1 = distance0 && Math.sqrt(distance1 / distance0);
}
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);
p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
scaleTo(scale1 * scale0);
......
This diff is collapsed.
......@@ -248,11 +248,8 @@ d3.behavior.zoom = function() {
}
if (l1) {
var scale1 = d3.event.scale;
if (scale1 == null) {
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
scale1 = distance0 && Math.sqrt(distance1 / distance0);
}
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1,
scale1 = distance0 && Math.sqrt(distance1 / distance0);
p0 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
l0 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
scaleTo(scale1 * scale0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment