svg.draw.js
svg.draw.js copied to clipboard
Stay subscribed to events.
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?
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');
});
const drawingFunc = function(e){
rect.draw('stop', e);
drawing.off('mouseup', drawingFunc)
}, false);`
drawing.on('mouseup', drawingFunc)