为什么Ember.run afterRender没有为CSS过渡工作?

Mic*_*ton 9 css-transitions ember.js

根据我的理解,使用CSS转换的一种方法是使用 Ember.run.scheduleOnce('afterRender')

但是,对我而言,如果不添加超时,则无法正常工作.这是在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);
    }
  },
});
Run Code Online (Sandbox Code Playgroud)

这是过去工作的东西,不再是,或者我错过了什么?

Jer*_*een 9

Ember.run.next 在这类事情上,我的工作非常顺利.

didInsertElement: function() {
  Ember.run.next(this, this.animateModalOpen);
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.在更仔细地阅读文档之后,很明显afterRender是在渲染DOM元素之后但在最终插入之前,因此可以进行尺寸计算等,但是对于css过渡来说太快了. (4认同)