sabato 7 gennaio 2017

Esempio di drag d3.js

js
function dragmove(d) {
    d3.select(this)
      .attr("y", d3.event.y)
      .attr("x", d3.event.x)
}

var drag = d3.behavior.drag()
    .on("drag", dragmove);

d3.select("body").append("svg")
    .attr("height", 300)
    .attr("width", 300)
    .append("text")
        .attr("x", 150)
        .attr("y", 150)
        .attr("id", "draggable")
        .text("Drag me bro!")
        .call(drag)


css
#draggable{
    text-anchor: start;
    cursor: pointer;
    text-anchor: middle;
}

Nessun commento:

Posta un commento