Drag and Drop

Haciendo uso del método drag cualquier objeto puede se arrastrado.

El método drag admite un objeto con las siguiente propiedades:

  • start: función ejecutada al momento de iniciar la acción.
  • move: función que se ejecuta mientras el objeto es arrastrado.
  • end: función a ejecutar al memento de soltar el objeto.
var ce = Cevent("canvas"),
    label;


ce.rect(50, 50, 40).attr("fill", "red").drag({
    move: function(c, e) {
        label.setText("Estoy en (" + c.x +", " + c.y +")");
    }
});

ce.circle(200, 100, 30).attr("fill", "green").drag({
    start: function(c, e) {
        this.alpha = .5;
        },
    end: function(c, e) {
        this.alpha = 1;
        }
});

label = ce.text(10, 10, "Estoy en (50, 50)").attr("fontSize", 15).get(-1);

// dibujar todo
ce.draw();

Related Topics

This Page

Fork me on GitHub