Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js Router: How to animate state transitions

Tags:

Has somebody found a good way to animate state transitions?

The router immediately removes the view from the DOM. The problem with that is that I can't defer that until the end of the animation. Note: I'm using v1.0.0-pre.4.

like image 296
david8401 Avatar asked Jan 25 '13 12:01

david8401


2 Answers

Billy's Billing just released an Ember module that supports animated transitions.

like image 101
camdub Avatar answered Dec 15 '22 02:12

camdub


I'll expand on Lesyk's answer. If you need to apply it to multiple views in a DRY way, you can create a customization class like this:

App.CrossfadeView = {   didInsertElement: function(){     //called on creation     this.$().hide().fadeIn(400);   },   willDestroyElement: function(){     //called on destruction     this.$().slideDown(250);   } }; 

And then in your code you apply it on your various view classes. As Ember depends on jQuery you can use pretty much any jQuery animation.

App.IndexView = Ember.View.extend(App.CrossfadeView); App.PostView = Ember.View.extend(App.CrossfadeView); 
like image 30
3 revs, 2 users 78% Avatar answered Dec 15 '22 03:12

3 revs, 2 users 78%