Snap.svg - drag event handler

后端 未结 6 831
广开言路
广开言路 2021-02-13 12:46

Question is about the onstart event handler for Element.drag in the newly announced Snap.svg.

The intention of the code below is to register event handlers for the start

6条回答
  •  囚心锁ツ
    2021-02-13 13:31

    Try this

    var paper = Snap("#main"); 
    
    var object  = paper.circle(300,150,100)
    object .attr({
      stroke: "#000",
      strokeWidth: 10,
      strokeLinecap:"round"
    }); 
    
    var move1 = function(dx,dy, posx, posy) { 
    this.transform(this.data('origTransform') + (this.data('origTransform') ? "T" : "t") + [dx, dy]) 
    };
    
    var start = function() {
            this.data('origTransform', this.transform().local );
    }
    var stop = function() {
            console.log('dragging done');
    }
    
    object.drag(move1, start, stop ); 
    

提交回复
热议问题