gigafied / ember-animate

Animations for Ember.js
Other
204 stars 28 forks source link

animateOut fails in certain situations #23

Open EmergentBehavior opened 10 years ago

EmergentBehavior commented 10 years ago

I currently have a component, let's call it some-component. I also have a template with logic similar to this:

{{#if somethingIsTrue}}
   {{some-component someStuff=...}}
{{else}}
   ...
{{/if}}

I have the following animation methods defined on the component:

willAnimateIn: function() {
        this.$().hide();
    },
    animateIn: function(done) {
        this.$().slideDown({ done: done });
    },
    animateOut: function(done) {
        this.$().slideUp({ done: done });
        Ember.run.later(this, done, 400);
    }

The animation in works fine, but the animation out does not. I tried it with and without Ember.run() but I think the problem is that the component itself is nested in some handlebars logic. What would be the proper way to perform an animateOut on this component before it was removed?

EmergentBehavior commented 10 years ago

I actually found a workaround here: https://www.youtube.com/watch?v=aFZ-b3pEK_Y

Basically, instead of using raw handlebars conditionals, you create animated-if and animated-unless components that can toggle visibility.

gigafied commented 10 years ago

Yeah, what happens is that if a view/component is nested in any way inside another element, it gets destroyed immediately :/ this is also an issue with the {{#each}} helper. Haven't been able to solve it yet, so in the meantime I would use that workaround.