Just to be consistent I would like to replace the loaded callback on SVG.Image with a loaded event.
I agree with that. In the fx module we use events, too but kept the during()/after() method for not breaking the api. Maybe we could remove this methods, too?
Yes, we should remove them everywhere.
The problem with events is, that they are awfully slow and that they only can be dispatched on nodes.
In the new fx module we dont have a node to dispatch. And creating a detached node only for dispatching events on it is highly memory intensive and leads to lots of garbage collections.
So my proposal is the following:
addEventListenerremoveEventListenergetEventDispatcherdispatchEventThis class should be completely able to remove and add events on its own.
However in case of SVG.Shapes we HAVE a node which we want to use. In that case getEventDispatcher returns a node and not this so that the events are bound and dispatched on the node instead of the object.
Note: Implementation has to be done on the 3.0 branch
For all questions head over to our gitter chat: https://gitter.im/svgdotjs/svg.js
This landed in 3.0 with 47fda3cf67cdc8ab20d3b1ba9d65a810adddf5ee in the following way:
EventTarget is a class that all classes can extend to get event handling.
It comes with the following interface:
on() bind the eventoff() unbind eventdispatch() dispatch an event on the object and return the eventfire() same as dispatch but returns the objectWhen you need to use a special event target (e.g. a node), you need to implement the following methods:
getEventTarget() returns the targetgetEventHolder() returns the object on which the events/listeners are savedAdditionally the target needs to implement:
addEventListener()removeEventListener() anddispatchEvent()The default is the EventTarget itself which implements all of these
Most helpful comment
This landed in 3.0 with 47fda3cf67cdc8ab20d3b1ba9d65a810adddf5ee in the following way:
EventTargetis a class that all classes can extend to get event handling.It comes with the following interface:
on()bind the eventoff()unbind eventdispatch()dispatch an event on the object and return the eventfire()same as dispatch but returns the objectWhen you need to use a special event target (e.g. a node), you need to implement the following methods:
getEventTarget()returns the targetgetEventHolder()returns the object on which the events/listeners are savedAdditionally the target needs to implement:
addEventListener()removeEventListener()anddispatchEvent()The default is the EventTarget itself which implements all of these