Here is the SVG text with anchor:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="width:200px;height:200px;">
<text x="50" y="30" fill="red" text-anchor="start">I love SVG</text>
</svg>
Now, if I write a drag and drop function:
var dragMove = function (d,i) {
d3.select(this).attr("x", d3.event.x)
.attr("y", d3.event.y);
};
var dragEnd = function (d,i) {
};
var drag = d3.behavior.drag()
.on("drag", dragMove)
.on("dragend", dragEnd);
d3.select("svg")
.select("text")
.call(drag);
It jumps after you drag it depending on its snap position. Is there a solution for this?
I tried to set the anchor-text to null and then set it again again, but this will not work. I don’t want the custom drag and drop mode to change at all. Even when the drag ends.
Any idea?
Here is the JSFiddle: http://jsfiddle.net/sewVr/
source
share