Fabric.js Tutorial – Part 5: Event

Fabric.js Tutorial – Part 5: Event


In this video, we’ll learn about event in Fabric.js There are many types of event that you can use in Fabric.js For example, a “selected” event will be fired when user clicked on the object You can bind an event handler by using “on” (simliar to jQuery) I’m going to add a console display to show you how “selected” event is fired You’ll see that “selected” will be fired when user is selecting. User has to deselect that object and select again in order to fire the event twice You can see the list of all supported event at Fabric.js documentation A note that some event such as scaling, moving, rotating will be fired continuously So you’ll need to be careful when handling these event Let’s try a “scaling” event You’ll see that the event was fired 67 times for a single scaling An alternative way if you want the event to fire once is to use “modified” event This event will fire once after the object has been modified In next video, we’ll take about how to export the entire canvas into downloadable png image Thanks for watching. Subscribe if you like us 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *