Skip to content
Browse files

cleaned up drag functionality, but now text elements all move to the …

…same place
  • Loading branch information...
1 parent 6a6c894 commit 43e50c5c16104aa5451cc0bebfa752aae127ecaf @turtlemonvh committed Feb 24, 2012
Showing with 9 additions and 12 deletions.
  1. +9 −12 src/mysite_test1/templates/createcards.html
View
21 src/mysite_test1/templates/createcards.html
@@ -316,6 +316,7 @@
}
// Function to call on svg drag
+ // PROBLEM: only works when drag is started horizontal left
// CAN WE ADD TO SELECTION?
function drag(){
var test_class = 'clicked_svg_card';
@@ -325,18 +326,14 @@
var dragTarget = d3.select(this);
dragTarget.attr("x", function(){return d3.event.dx + parseInt(dragTarget.attr("x"))});
dragTarget.attr("y", function(){return d3.event.dy + parseInt(dragTarget.attr("y"))});
-
- // Move text - NEED TO DO THIS BETTER
- dragTarget = d3.select($(this).parent().find("text")[0]);
- dragTarget.attr("x", function(){return d3.event.dx + parseInt(dragTarget.attr("x"))})
- dragTarget.attr("y", function(){return d3.event.dy + parseInt(dragTarget.attr("y"))});
-
- dragTarget = d3.select($(this).parent().find("text")[1]);
- dragTarget.attr("x", function(){return d3.event.dx + parseInt(dragTarget.attr("x"))})
- dragTarget.attr("y", function(){return d3.event.dy + parseInt(dragTarget.attr("y"))});
-
- dragTarget = d3.select($(this).parent().find("text")[2]);
- dragTarget.attr("x", function(){return d3.event.dx + parseInt(dragTarget.attr("x"))})
+
+ // Move text
+ dragTarget = d3.selectAll($(this).parent().find("text").get());
+
+ // Fix this so the text position changes for each separately
+ // Probably need to get data from each element separately
+ dragTarget
+ .attr("x", function(){return d3.event.dx + parseInt(dragTarget.attr("x"))})
.attr("y", function(){return d3.event.dy + parseInt(dragTarget.attr("y"))});
} else {
console.log("not draggable without selecting first");

0 comments on commit 43e50c5

Please sign in to comment.
Something went wrong with that request. Please try again.