Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Ember.run afterRender not working for CSS transitions?

From my understanding, one way to work with CSS transitions is to use Ember.run.scheduleOnce('afterRender')

However, for me it is not working without adding a timeout. This is in Ember 1.0.0

View = Em.View.extend({
  didInsertElement: function() {
    Ember.run.scheduleOnce('afterRender', this, 'animateModalOpen');
  },

  animateModalOpen: function() {
    // this does not work - modal gets styles from class "in" with no transition
    $('.modal').addClass('in');

    // this does work, the transition is fired
      setTimeout(function() {
        $('.modal').addClass('in');
      }, 1);
    }
  },
});

Is this something that used to work and just doesn't anymore, or am I missing something?

like image 221
Michael Johnston Avatar asked Sep 16 '13 22:09

Michael Johnston


1 Answers

Ember.run.next has worked very well for me on this type of thing.

didInsertElement: function() {
  Ember.run.next(this, this.animateModalOpen);
}
like image 115
Jeremy Green Avatar answered Sep 19 '22 10:09

Jeremy Green