Snap.svg - drag event handler

后端 未结 6 821
广开言路
广开言路 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:41

    I can't drag group elements with custom handlers, s.drag() makes it possible. So i searched further found its possible.

    Documentation:

    Additionaly following drag events are triggered: drag.start. on start, drag.end. on > end and drag.move. on every move. When element is dragged over another element > drag.over. fires as well.

    Solution:

        s.drag();
        eve.on("snap.drag.start." + s.id, function () {
            console.log('cool');
        });
    
        eve.on("snap.drag.move." + s.id, function () {
            console.log('cooler');
        });
    
        eve.on("snap.drag.end." + s.id, function () {
            console.log('way cool');
        });
    

    eve is not documented on snapsvg it is available on raphael. i don't know this is proper way or hack.

提交回复
热议问题