博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery queue() dequeue() clearQueue() 方法 动画的手动播放与暂停
阅读量:3951 次
发布时间:2019-05-24

本文共 1932 字,大约阅读时间需要 6 分钟。

queue() 方法, dequeue() 方法

元素可以有多个队列附加到它们上,我们可以为每个队列赋予不同的名称。我们可以 指定一个自定义队列名称 作为.queue()方法的第一个参数。

官方文档:Elements can have multiple queues attached to them, and we can give each of these queues a different name. We can specify a custom queue name as the first argument to the .queue() method.

队列是 jQuery 中所有动画的基础,它们允许在一个元素上异步执行一系列函数,当使用.animate()时,此方法会利用队列构建一系列步骤,这些步骤将在整个动画期间转换一个或多个CSS值。

官方文档:Queues are the foundation for all animations in jQuery, they allow a series functions to be executed asynchronously on an element. Methods such as .slideUp(), .slideDown(), .fadeIn(), and .fadeOut() all use .animate(), which leverages queues to build up the series of steps that will transition one or more CSS values throughout the duration of the animation.

jquery 对队列项的功能没有明确排序,因此我们需要调用 .dequeue() ,它告诉 jquery 何时移动到队列中的下一个项。因此,queue() 方法通常与 dequeue() 方法一起使用。

官方文档:jQuery does not have any insight into how the queue items function, so we need to call .dequeue(), which tells jQuery when to move to the next item in the queue.

        
queue(),dequeue(),clearQueue()

queue() 方法允许你创建一个队列功能区执行被选中的元素。

dequeue() 方法顺序执行它们。

clearQueue() 方法

因为队列只是一组有序的操作,所以我们的应用程序可能有一些逻辑,需要防止剩余的队列条目继续执行。此方面可以通过调用 .clearQueue() 方法来实现这一点,该方法将清空对应的队列。

Since queues are just a set of ordered operations, our application may have some logic in place that needs to prevent the remaining queue entries from executing. We can do this by calling the .clearQueue() method, which will empty the queue.

.stop() 方法(只适用于动画)不同的是,.clearQueue() 方法移除任何排队的函数。

        
queue(),dequeue(),clearQueue()

queue() 方法允许你创建一个队列功能区执行被选中的元素。

dequeue() 方法顺序执行它们。


15580222-0f19a59a045ea02e
image

demo 实现动画的手动播放与暂停

        
queue(),dequeue(),clearQueue()

queue() 方法允许你创建一个队列功能区执行被选中的元素。

dequeue() 方法顺序执行它们。



Reference

转载地址:http://sghwi.baihongyu.com/

你可能感兴趣的文章
一切悲剧都源于不当激励
查看>>
别把用户的高期望混同于好体验
查看>>
动机和机会:推动商业发展的引擎
查看>>
4个信号表明你是一个失败的领导
查看>>
成功谈判 你需要几个锦囊?
查看>>
一个人的宽度决定了他的高度
查看>>
善于拜访是另一种经营智慧
查看>>
打造新老员工双赢机制变对立为统一
查看>>
企业如何避免用错人
查看>>
打掉苹果“无与伦比”的傲慢(人民时评)
查看>>
Creating an Android Project
查看>>
Running Your App (android)
查看>>
Starting Another Activity
查看>>
Starting an Activity
查看>>
Stopping and Restarting an Activity
查看>>
Using the Support Library
查看>>
Creating a Fragment
查看>>
Building a Flexible UI
查看>>
Communicating with Other Fragments
查看>>
Saving Key-Value Sets
查看>>