svg.draw.js icon indicating copy to clipboard operation
svg.draw.js copied to clipboard

Stay subscribed to events.

Open sysmaya opened this issue 3 years ago • 2 comments

Why continue drawing after created?

`drawing.on('mousedown', function(e){ rect.draw(e); console.log('this event happens after created'); }, false);

    drawing.on('mouseup', function(e){
        rect.draw('stop', e);
        console.log('this event happens after created');
    }, false);`

QUESTION: How do I unsubscribe from the events after the form is created?

sysmaya avatar Aug 17 '22 00:08 sysmaya

I need to use this plugin, so with the help of Jquery, I solve the problem. It's not an elegant solution, but it works. Voila!

var drawing = new SVG('rectNoClick').size('100%', '100%').id('ssvvgg');; var rect = drawing.rect().attr('stroke-width',1).attr('fill','aqua');

    $("#ssvvgg").one("mousedown", function(e){
        rect.draw(e);
        console.log('this event happens JUST ONCE');
    });

    $("#ssvvgg").one("mouseup", function(e){
        rect.draw(e);
        console.log('this event happens JUST ONCE');
    });

sysmaya avatar Aug 17 '22 00:08 sysmaya

const drawingFunc = function(e){
  rect.draw('stop', e);
  drawing.off('mouseup', drawingFunc)
}, false);`

drawing.on('mouseup', drawingFunc)

Fuzzyma avatar Aug 17 '22 07:08 Fuzzyma