Add class to image on load
benjaminleonard opened this issue · comments
Hey, I wanted to add a class to the image when it had finished loaded. I added this to the setSource function:
node.onload = function() { node.classList.add('loaded'); }
Is it worth adding this to the library? Seems like browser support is decent.
@benjaminleonard check out the events system - a combination of src:before
and src:after
events handles situations like this and many more. You can bind the load event in the src:before
, for similar functionality.
Rather than do something prescriptive, like add a class, I prefer to expose events/hooks that are extendable, and let users do what they need - and only what they need - using them.
Makes sense, thanks!
No problemo, good question.