Permalink
Browse files

Compute node position relative to parent.

Previously, we were computing the node position relative to the node, which is
dangerous is the node is transformed. Computing it relative to the parent allows
nodes to be positioned using the "transform" attribute.
  • Loading branch information...
1 parent f76e515 commit 603d86ac1a135bb73a07bd74a0cedfd5942a32be @mbostock mbostock committed May 1, 2011
Showing with 10 additions and 8 deletions.
  1. +1 −1 d3.js
  2. +3 −2 d3.layout.js
  3. +1 −1 d3.layout.min.js
  4. +1 −1 d3.min.js
  5. +1 −1 src/core/core.js
  6. +3 −2 src/layout/force.js
View
2 d3.js
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.14.0"}; // semver
+(function(){d3 = {version: "1.14.1"}; // semver
if (!Date.now) Date.now = function() {
return +new Date();
};
View
@@ -396,15 +396,16 @@ d3.layout.force = function() {
function dragmove() {
if (!d3_layout_forceDragNode) return;
+ var parent = d3_layout_forceDragElement.parentNode;
// O NOES! The drag element was removed from the DOM.
- if (!d3_layout_forceDragElement.parentNode) {
+ if (!parent) {
d3_layout_forceDragNode.fixed = false;
d3_layout_forceDragNode = d3_layout_forceDragElement = null;
return;
}
- var m = d3.svg.mouse(d3_layout_forceDragElement);
+ var m = d3.svg.mouse(parent);
d3_layout_forceDragMoved = true;
d3_layout_forceDragNode.px = m[0];
d3_layout_forceDragNode.py = m[1];
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -1 +1 @@
-d3 = {version: "1.14.0"}; // semver
+d3 = {version: "1.14.1"}; // semver
View
@@ -244,15 +244,16 @@ d3.layout.force = function() {
function dragmove() {
if (!d3_layout_forceDragNode) return;
+ var parent = d3_layout_forceDragElement.parentNode;
// O NOES! The drag element was removed from the DOM.
- if (!d3_layout_forceDragElement.parentNode) {
+ if (!parent) {
d3_layout_forceDragNode.fixed = false;
d3_layout_forceDragNode = d3_layout_forceDragElement = null;
return;
}
- var m = d3.svg.mouse(d3_layout_forceDragElement);
+ var m = d3.svg.mouse(parent);
d3_layout_forceDragMoved = true;
d3_layout_forceDragNode.px = m[0];
d3_layout_forceDragNode.py = m[1];

0 comments on commit 603d86a

Please sign in to comment.