如何在jQuery中使用transitionend? [英] How do I use transitionend in jQuery?

查看:392
本文介绍了如何在jQuery中使用transitionend?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在允许功能再次重复之前检测CSS过渡是否已完成,以免弄乱边距.

I need to detect if a CSS transition is completed before allowing a function to repeat again, to prevent messing up the margins.

所以我有类似的东西

if (transitionend == true) {
  // do stuff
} else {
  // do nothing
}

推荐答案

下面的代码将在transitionend事件上触发您在$ element变量中具有的任何元素.我认为有四种不同的事件名称,因为它们涵盖了所有跨浏览器不一致的地方.用触发事件时希望运行的任何代码替换"//您的事件处理程序"注释.

The code below will trigger on the transitionend event for whatever element(s) you have in the $element variable. There are four different event names as I believe these cover all of the cross-browser inconsistencies. Replace the '// your event handler' comment with whatever code you wish to run when the event is triggered.

$element.on('transitionend webkitTransitionEnd oTransitionEnd', function () {
    // your event handler
});

这篇关于如何在jQuery中使用transitionend?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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