javascript - Removing the item being clicked -


i created canvas , can add objects. how can remove item clicked?

var canvas = new fabric.canvas('c'); var rect = new fabric.rect({   left: 50,   top: 50,   fill: 'green',   width: 40,   height: 80 }); var circle = new fabric.circle({   radius: 20,    fill: 'red',    left: 100,    top: 100 }); canvas.add(rect); canvas.add(circle); 

fabric.js provides object:selected event on canvas. can listen event , remove item occurred on. here's sample code:

canvas.on('object:selected',function(ev){     canvas.remove(ev.target); }); 

you can read documentation , @ jsfiddle created here: http://jsfiddle.net/yrl4elsn/1/


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -