9

据我了解,使用 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);
    }
  },
});

这是曾经有效但不再有效的东西,还是我错过了什么?

4

1 回答 1

9

Ember.run.next在这类事情上对我来说效果很好。

didInsertElement: function() {
  Ember.run.next(this, this.animateModalOpen);
}
于 2013-09-17T02:42:00.130 回答