ember-animation/liquid-fire

willDestroy should be called before the transition starts

gedaiu opened this issue · 2 comments

I have a custom map component that can be present only once in the DOM. By using the route transition, this component will be rendered twice while the animation is running. It would be nice to give it the ability to handle this in the willDestroy event.

ef4 commented

This is fundamental to how liquid-fire (and ember-animated) work.

If you want to animate between two screens that each have your component on them, both copies truly are on the screen at the same time and the components need to play well with each other.

If we tried to leave half-destroyed components around for the whole lifetime of the animation, lots of potentially undefined behaviors crop up. Users could start interacting with them in between their willDestroy and their actual destroy. And the start of a transition is too soon to actually know if we're really) going to destroy them at all, because transitions can get interrupted.

If you have a component that really must be a global singleton, then it should be a real global singleton (in only one template, possible a high one like application.hbs). You can still manipulate its geometry so that it's positioned correctly relative to whichever current route you happen to be on, so that is looks like it's "inside" various child routes, even though the component keeps its state and doesn't ever destroyed.

It makes sense. Initially i was thinking that I can disable all the user interaction with the component by replacing it with a picture.

I will update my component to work with at least 2 instances.
Thanks!