Closed colin-aarts closed 7 years ago
This would be very helpful to have
This is actually a feature of Marko v4, but I'm realizing it is not documented anywhere. Marko v4 supports on-attach
and on-detach
events for any DOM elements that can be used to animate in and animate out DOM elements from the DOM. You can see it in action here: http://markojs.com/try-online/?file=%2Ftodomvc%2Fcomponents%2Ftodomvc-todo-item%2Fdemo.marko&gist=
Calling event.preventDefault()
in the on-detach
event handler prevents an element from being removed from the DOM. After the animation has been completed you should call event.detach();
to complete the removal of the DOM element out of the DOM.
I'll open an issue on the main marko repo to document this feature.
Having a mechanism for delaying destruction of a widget from a widget's
onBeforeDestroy
(or similar) callback would be useful for a number of cases, such as easily running teardown animations, without having to micro-manage that from outside. E.g, based on Glitter discussion: