Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
mbostock committed Aug 22, 2011
2 parents 402c2e4 + 6659863 commit b21cc8138db1e3ad5b6e658ac3d144b45fcc85e6
Showing with 85 additions and 46 deletions.
  1. +18 −3 d3.behavior.js
  2. +1 −1 d3.behavior.min.js
  3. +6 −6 d3.js
  4. +13 −12 d3.layout.js
  5. +1 −1 d3.layout.min.js
  6. +1 −1 d3.min.js
  7. +1 −1 examples/sizzle/sizzle.html
  8. +7 −0 examples/zoom-pan/zoom-pan.html
  9. +18 −3 src/behavior/zoom.js
  10. +5 −5 src/core/array.js
  11. +1 −1 src/core/core.js
  12. +1 −1 src/layout/chord.js
  13. +12 −11 src/layout/force.js
View
@@ -17,7 +17,8 @@ d3.behavior.zoom = function() {
.on("mousemove.zoom", d3_behavior_zoomMousemove)
.on("mouseup.zoom", d3_behavior_zoomMouseup)
.on("touchmove.zoom", d3_behavior_zoomTouchmove)
- .on("touchend.zoom", d3_behavior_zoomTouchup);
+ .on("touchend.zoom", d3_behavior_zoomTouchup)
+ .on("click.zoom", d3_behavior_zoomClick, true);
}
// snapshot the local context for subsequent dispatch
@@ -31,6 +32,7 @@ d3.behavior.zoom = function() {
function mousedown() {
start.apply(this, arguments);
d3_behavior_zoomPanning = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget));
+ d3_behavior_zoomMoved = false;
d3.event.preventDefault();
window.focus();
}
@@ -76,7 +78,8 @@ var d3_behavior_zoomDiv,
d3_behavior_zoomXyz,
d3_behavior_zoomDispatch,
d3_behavior_zoomTarget,
- d3_behavior_zoomArguments;
+ d3_behavior_zoomArguments,
+ d3_behavior_zoomStopClick;
function d3_behavior_zoomLocation(point) {
return [
@@ -155,16 +158,28 @@ function d3_behavior_zoomTouchmove() {
function d3_behavior_zoomMousemove() {
d3_behavior_zoomZooming = null;
- if (d3_behavior_zoomPanning) d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
+ if (d3_behavior_zoomPanning) {
+ d3_behavior_zoomMoved = true;
+ d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
+ }
}
function d3_behavior_zoomMouseup() {
if (d3_behavior_zoomPanning) {
+ if (d3_behavior_zoomMoved) d3_behavior_zoomStopClick = true;
d3_behavior_zoomMousemove();
d3_behavior_zoomPanning = null;
}
}
+function d3_behavior_zoomClick() {
+ if (d3_behavior_zoomStopClick) {
+ d3.event.stopPropagation();
+ d3.event.preventDefault();
+ d3_behavior_zoomStopClick = false;
+ }
+}
+
function d3_behavior_zoomTo(z, x0, x1) {
var K = Math.pow(2, (d3_behavior_zoomXyz[2] = z) - x1[2]),
x = d3_behavior_zoomXyz[0] = x0[0] - K * x1[0],
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
12 d3.js
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.29.6"}; // semver
+(function(){d3 = {version: "1.29.7"}; // semver
if (!Date.now) Date.now = function() {
return +new Date;
};
@@ -9,14 +9,14 @@ if (!Object.create) Object.create = function(o) {
};
var d3_array = d3_arraySlice; // conversion for NodeLists
-function d3_arrayCopy(psuedoarray) {
- var i = -1, n = psuedoarray.length, array = [];
- while (++i < n) array.push(psuedoarray[i]);
+function d3_arrayCopy(pseudoarray) {
+ var i = -1, n = pseudoarray.length, array = [];
+ while (++i < n) array.push(pseudoarray[i]);
return array;
}
-function d3_arraySlice(psuedoarray) {
- return Array.prototype.slice.call(psuedoarray);
+function d3_arraySlice(pseudoarray) {
+ return Array.prototype.slice.call(pseudoarray);
}
try {
View
@@ -143,7 +143,7 @@ d3.layout.chord = function() {
if (source.value || target.value) {
chords.push(source.value < target.value
? {source: target, target: source}
- : {source: source, target: target})
+ : {source: source, target: target});
}
}
}
@@ -269,10 +269,10 @@ d3.layout.force = function() {
l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
x *= l;
y *= l;
- t.x -= x;
- t.y -= y;
- s.x += x;
- s.y += y;
+ t.x -= x / t.weight;
+ t.y -= y / t.weight;
+ s.x += x / s.weight;
+ s.y += y / s.weight;
}
}
@@ -387,6 +387,7 @@ d3.layout.force = function() {
for (i = 0; i < n; ++i) {
(o = nodes[i]).index = i;
+ o.weight = 0;
}
distances = [];
@@ -397,6 +398,8 @@ d3.layout.force = function() {
if (typeof o.target == "number") o.target = nodes[o.target];
distances[i] = linkDistance.call(this, o, i);
strengths[i] = linkStrength.call(this, o, i);
+ ++o.source.weight;
+ ++o.target.weight;
}
for (i = 0; i < n; ++i) {
@@ -468,7 +471,7 @@ d3.layout.force = function() {
function dragdown(d, i) {
var m = d3_layout_forcePoint(this.parentNode);
- (d3_layout_forceDragNode = d).fixed = true;
+ (d3_layout_forceDragNode = d).fixed |= 2;
d3_layout_forceDragMoved = false;
d3_layout_forceDragElement = this;
d3_layout_forceDragForce = force;
@@ -487,13 +490,11 @@ var d3_layout_forceDragForce,
d3_layout_forceDragElement;
function d3_layout_forceDragOver(d) {
- d.fixed = true;
+ d.fixed |= 2;
}
function d3_layout_forceDragOut(d) {
- if (d !== d3_layout_forceDragNode) {
- d.fixed = false;
- }
+ if (d !== d3_layout_forceDragNode) d.fixed &= 1;
}
function d3_layout_forcePoint(container) {
@@ -508,7 +509,7 @@ function d3_layout_forceDragMove() {
// O NOES! The drag element was removed from the DOM.
if (!parent) {
- d3_layout_forceDragNode.fixed = false;
+ d3_layout_forceDragNode.fixed &= 1;
d3_layout_forceDragOffset = d3_layout_forceDragNode = d3_layout_forceDragElement = null;
return;
}
@@ -534,7 +535,7 @@ function d3_layout_forceDragUp() {
if (d3.event.type === "mouseup") d3_layout_forceDragMove();
}
- d3_layout_forceDragNode.fixed = false;
+ d3_layout_forceDragNode.fixed &= 1;
d3_layout_forceDragForce =
d3_layout_forceDragOffset =
d3_layout_forceDragNode =
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -18,7 +18,7 @@
Sizzle.js disabled.
<script type="text/javascript">
-// The :first psuedo-class is a custom Sizzle extension.
+// The :first pseudo-class is a custom Sizzle extension.
d3.select("body:first")
.html("Sizzle.js enabled!");
@@ -47,6 +47,13 @@
.attr("stroke", stroke)
.attr("fill", "none");
+svg.append("svg:a")
+ .attr("xlink:href", "http://mbostock.github.com/d3/")
+ .append("svg:text")
+ .style("font-size", "3em")
+ .attr("transform", "translate(110.5, 110.5)")
+ .text("D3.js");
+
redraw();
function redraw() {
View
@@ -16,7 +16,8 @@ d3.behavior.zoom = function() {
.on("mousemove.zoom", d3_behavior_zoomMousemove)
.on("mouseup.zoom", d3_behavior_zoomMouseup)
.on("touchmove.zoom", d3_behavior_zoomTouchmove)
- .on("touchend.zoom", d3_behavior_zoomTouchup);
+ .on("touchend.zoom", d3_behavior_zoomTouchup)
+ .on("click.zoom", d3_behavior_zoomClick, true);
}
// snapshot the local context for subsequent dispatch
@@ -30,6 +31,7 @@ d3.behavior.zoom = function() {
function mousedown() {
start.apply(this, arguments);
d3_behavior_zoomPanning = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget));
+ d3_behavior_zoomMoved = false;
d3.event.preventDefault();
window.focus();
}
@@ -75,7 +77,8 @@ var d3_behavior_zoomDiv,
d3_behavior_zoomXyz,
d3_behavior_zoomDispatch,
d3_behavior_zoomTarget,
- d3_behavior_zoomArguments;
+ d3_behavior_zoomArguments,
+ d3_behavior_zoomStopClick;
function d3_behavior_zoomLocation(point) {
return [
@@ -154,16 +157,28 @@ function d3_behavior_zoomTouchmove() {
function d3_behavior_zoomMousemove() {
d3_behavior_zoomZooming = null;
- if (d3_behavior_zoomPanning) d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
+ if (d3_behavior_zoomPanning) {
+ d3_behavior_zoomMoved = true;
+ d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
+ }
}
function d3_behavior_zoomMouseup() {
if (d3_behavior_zoomPanning) {
+ if (d3_behavior_zoomMoved) d3_behavior_zoomStopClick = true;
d3_behavior_zoomMousemove();
d3_behavior_zoomPanning = null;
}
}
+function d3_behavior_zoomClick() {
+ if (d3_behavior_zoomStopClick) {
+ d3.event.stopPropagation();
+ d3.event.preventDefault();
+ d3_behavior_zoomStopClick = false;
+ }
+}
+
function d3_behavior_zoomTo(z, x0, x1) {
var K = Math.pow(2, (d3_behavior_zoomXyz[2] = z) - x1[2]),
x = d3_behavior_zoomXyz[0] = x0[0] - K * x1[0],
View
@@ -1,13 +1,13 @@
var d3_array = d3_arraySlice; // conversion for NodeLists
-function d3_arrayCopy(psuedoarray) {
- var i = -1, n = psuedoarray.length, array = [];
- while (++i < n) array.push(psuedoarray[i]);
+function d3_arrayCopy(pseudoarray) {
+ var i = -1, n = pseudoarray.length, array = [];
+ while (++i < n) array.push(pseudoarray[i]);
return array;
}
-function d3_arraySlice(psuedoarray) {
- return Array.prototype.slice.call(psuedoarray);
+function d3_arraySlice(pseudoarray) {
+ return Array.prototype.slice.call(pseudoarray);
}
try {
View
@@ -1 +1 @@
-d3 = {version: "1.29.6"}; // semver
+d3 = {version: "1.29.7"}; // semver
View
@@ -85,7 +85,7 @@ d3.layout.chord = function() {
if (source.value || target.value) {
chords.push(source.value < target.value
? {source: target, target: source}
- : {source: source, target: target})
+ : {source: source, target: target});
}
}
}
View
@@ -63,10 +63,10 @@ d3.layout.force = function() {
l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
x *= l;
y *= l;
- t.x -= x;
- t.y -= y;
- s.x += x;
- s.y += y;
+ t.x -= x / t.weight;
+ t.y -= y / t.weight;
+ s.x += x / s.weight;
+ s.y += y / s.weight;
}
}
@@ -181,6 +181,7 @@ d3.layout.force = function() {
for (i = 0; i < n; ++i) {
(o = nodes[i]).index = i;
+ o.weight = 0;
}
distances = [];
@@ -191,6 +192,8 @@ d3.layout.force = function() {
if (typeof o.target == "number") o.target = nodes[o.target];
distances[i] = linkDistance.call(this, o, i);
strengths[i] = linkStrength.call(this, o, i);
+ ++o.source.weight;
+ ++o.target.weight;
}
for (i = 0; i < n; ++i) {
@@ -262,7 +265,7 @@ d3.layout.force = function() {
function dragdown(d, i) {
var m = d3_layout_forcePoint(this.parentNode);
- (d3_layout_forceDragNode = d).fixed = true;
+ (d3_layout_forceDragNode = d).fixed |= 2;
d3_layout_forceDragMoved = false;
d3_layout_forceDragElement = this;
d3_layout_forceDragForce = force;
@@ -281,13 +284,11 @@ var d3_layout_forceDragForce,
d3_layout_forceDragElement;
function d3_layout_forceDragOver(d) {
- d.fixed = true;
+ d.fixed |= 2;
}
function d3_layout_forceDragOut(d) {
- if (d !== d3_layout_forceDragNode) {
- d.fixed = false;
- }
+ if (d !== d3_layout_forceDragNode) d.fixed &= 1;
}
function d3_layout_forcePoint(container) {
@@ -302,7 +303,7 @@ function d3_layout_forceDragMove() {
// O NOES! The drag element was removed from the DOM.
if (!parent) {
- d3_layout_forceDragNode.fixed = false;
+ d3_layout_forceDragNode.fixed &= 1;
d3_layout_forceDragOffset = d3_layout_forceDragNode = d3_layout_forceDragElement = null;
return;
}
@@ -328,7 +329,7 @@ function d3_layout_forceDragUp() {
if (d3.event.type === "mouseup") d3_layout_forceDragMove();
}
- d3_layout_forceDragNode.fixed = false;
+ d3_layout_forceDragNode.fixed &= 1;
d3_layout_forceDragForce =
d3_layout_forceDragOffset =
d3_layout_forceDragNode =

0 comments on commit b21cc81

Please sign in to comment.