I am trying to make some animated transitions between connecting different points. I know that there are methods like willInsertElement , didInsertElement or willDestroyElement of the View class, which you can override, but you cannot delay adding or, especially, deleting an element. I tried to override other methods, but looking at a class is hard to understand how it works. I came up with some idea:
Jsfiddle example
AnimationHelper = Ember.Object.extend({ isPreviousViewFadedOut:false, nextViewToFadeIn:null, triggerManually: true, setNextViewToFadeIn:function (view) { if (this.nextViewToFadeIn) { if (this.hasObserverFor('isPreviousViewFadedOut')) { this.removeObserver('isPreviousViewFadedOut', this.nextViewToFadeIn, 'fadeInCallback'); } } this.nextViewToFadeIn = view; this.addObserver('isPreviousViewFadedOut', this.nextViewToFadeIn, 'fadeInCallback'); } }); AnimatedView = Ember.View.extend({ didInsertElement:function () { this.$().hide(); if (AnimatedView.aHelper.get('triggerManually')) { AnimatedView.aHelper.set('isPreviousViewFadedOut', true); this.fadeInCallback();
Everything seems to be fine, but it's probably a very bad design. Is there a better way to achieve this effect? or maybe I'm completely wrong and should look at the problem from very different points of view? for example, make an animation inside the View that wraps another view, etc.
source share