简体   繁体   English

setTimeout排队时间问题

[英]setTimeout queuing timing issues

I am having issues with the timing of a game. 我在比赛时间上有疑问。 Everything works when the start button is clicked for the first time or the user waits long enough before clicking the button again. 第一次单击开始按钮时,一切正常,或者用户等待足够长的时间再再次单击该按钮。

Otherwise just the audio fires but the rotation transisitons do not. 否则,只会触发音频,而不会产生旋转过渡。 The rotation transitions are created using transit.js 旋转过渡是使用transit.js创建的

I have tried using clearQueue at the end of tock loop and on the reset button but it has no effect. 我已经尝试在tock循环的结尾和reset按钮上使用clearQueue,但是它没有任何效果。

I am trying to achieve:- all animation queues to clear when the start or reset buttons are clicked. 我正在尝试实现:-单击开始或重置按钮时清除所有动画队列。

My code 我的密码

The transit.js that your using is css3 animation. 您使用的transit.js是css3动画。 Thats why when you call clearQueue its not stopping the animation. 因此,当您调用clearQueue时,它不会停止动画。 clearQueue only clears jQuery animation clearQueue仅清除jQuery动画

To stop css3, you'll probably have to do something like this. 要停止css3,您可能必须执行以下操作。

$('#drive, .wheel').css("-webkit-transform", "none");
$('#drive, .wheel').css("-moz-transform", "none");
$('#drive, .wheel').css("-ms-transform", "none");
$('#drive, .wheel').css("transform", "none");

Depending on the situation but i'm not a big fan of CSS3 animation as yet, because alot of work i have to do need to support IE. 视情况而定,但我还不是CSS3动画的忠实支持者,因为我要做的很多工作都需要支持IE。 (css3 doesn't work on IE9 or older). (css3在IE9或更低版本上不起作用)。 For now if you just wanna rotate, i would use http://code.google.com/p/jqueryrotate/ 现在,如果您只想旋转,我会使用http://code.google.com/p/jqueryrotate/

then 然后

$(element).stop()

and

$(element).clearQueue()

will work 将工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM