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

蓝咒 提交于 2019-12-18 15:42:30

问题


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?


回答1:


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

didInsertElement: function() {
  Ember.run.next(this, this.animateModalOpen);
}


来源:https://stackoverflow.com/questions/18838405/why-is-ember-run-afterrender-not-working-for-css-transitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!