为什么 Ember.run afterRender 不适用于 CSS 过渡? [英] Why is Ember.run afterRender not working for CSS transitions?

查看:14
本文介绍了为什么 Ember.run afterRender 不适用于 CSS 过渡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,处理 CSS 过渡的一种方法是使用 Ember.run.scheduleOnce('afterRender')

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

但是,对我来说,如果不添加超时,它就不起作用.这是在 Ember 1.0.0

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?

推荐答案

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

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

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

这篇关于为什么 Ember.run afterRender 不适用于 CSS 过渡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆