[英]JQuery wait until ToggleClass function completed
I am using ToggleClass to trigger an animation from css and need to call a function after the animation has ended. 我正在使用ToggleClass从CSS触发动画,并且动画结束后需要调用函数。 I'm calling a function from the typed.js library.
我正在从typed.js库调用一个函数。
$('.anim').toggleClass('slide-down');
$(".sentence").typed({
strings: ["first sentence", "Second sentence." ],
typeSpeed: 45,
backDelay: 500,
callback: function(){}
});
how can I make the typed function wait till the toggleClass has finished? 我怎样才能让类型化的函数等到toggleClass完成?
You can wait for the animationend event 您可以等待animationend事件
$('.anim').toggleClass('slide-down').one('animationend', function () {
$(".sentence").typed({
strings: ["first sentence", "Second sentence."],
typeSpeed: 45,
backDelay: 500,
callback: function () {}
});
});
Or if you are using transition, then use transitionend 或者,如果您使用过渡,请使用transitionend
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.