- 浏览: 607765 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (228)
- io (15)
- cluster (16)
- linux (7)
- js (23)
- bizarrerie (46)
- groovy (1)
- thread (1)
- jsp (8)
- static (4)
- cache (3)
- protocol (2)
- ruby (11)
- hibernate (6)
- svn (1)
- python (8)
- spring (19)
- gma (1)
- architecture (4)
- search (15)
- db (3)
- ibatis (1)
- html5 (1)
- iptables (1)
- server (5)
- nginx (4)
- scala (1)
- DNS (1)
- jPlayer (1)
- Subversion 版本控制 (1)
- velocity (1)
- html (1)
- ppt poi (1)
- java (1)
- bizarrerie spring security (1)
最新评论
-
koreajapan03:
楼主啊,好人啊,帮我解决了问题,谢谢
自定义过滤器时,不能再使用<sec:authorize url="">问题 -
snailprince:
请问有同一页面,多个上传实例的例子吗
webuploader用java实现上传 -
wutao8818:
姚小呵 写道如何接收server返回的参数呢?例如你返回的是“ ...
webuploader用java实现上传 -
姚小呵:
如何接收server返回的参数呢?例如你返回的是“1”,上传的 ...
webuploader用java实现上传 -
zycjf2009:
你好,我想用jplayer做一个简单的播放器,但是因为对js不 ...
jplayer 实战
What is a Queue
Let’s examine how events in a queue occur: For a programmer a queue is an Array with events that are stacked on each other to be handled one by one. For example, a user hovers over a button with his cursor and then after half a second leaves the button area again. Two events have taken place, the mouseover and the mouseout. If you would handle the mouseover and the mouseout event takes place, it could disturb your current process. However you can’t just ignore the event, because then you will be stuck in the status that is established by the actions you have performed for mouseover. In this situation you could add the event to a queue and every time you’re done with processing an event, just check the queue for unprocessed events (and act accordingly).
How do Effects work and why do you need a Queue
The same happens when you are dealing with Effects and you face the situation where two effects can be called, both of which manipulate the same DOM object(s). script.aculo.us comes to the rescue with several techniques to manage your effects. To explain this further, we will show you how things work by example.
什么是queue? 为了解决对同一个元素触发多个处理效果时需要解决效果发生的先后顺序问题。通过Queue队列的形式将并行的效果按我们的先后顺序串行化。
Effect.Queue
The previous examples gave you an idea of the situations you could be facing without Queues. This must give you some motivation to find how Effect.Queue could improve your live and help you to manage your Effects.
Effect.Queue is an improved array of Effects (called Enumerable) that is global for the entire page. It gets created by extracting the global queue from Effect.Queues (we will discuss this later). So all effects you want to queue will be added to the ‘global’ queue. You might be wondering how to add an effect to the queue? Well it’s quite easy.
Effect.Queue是一个改进的Effects数组。此对象作用范围为页面全局可访问。
So you see I have added an array containing an entry “queue:” with the value “end”. This means that the Effect will be inserted at the end of the “global” Queue. All effects are always added to the queue, however without a position like ‘end’ they are always executed parallel to the other effects.
如果没有queue:end,效果将并行的执行。
Remember that JavaScript is not multi-threaded, so blocks of code are executed together when they get parsed. This causes the effects to start in parallel if no queue is defined.
This works nicely, doesn’t it? But what happens when you queue all kinds of effects in different places? You could have lots of effects that you would like to queue but they don’t all relate to each other. This is where Effect.ScopedQueue comes in.
Basic Effect.ScopedQueue
As explained before, the default Queue is ‘global’. All effects are placed in the ‘global’ Queue unless you define a different scope. A scope is nothing more than grouping a set of Effects together in their own Queue. To do this, you need to pass an array instead of a string to the “queue:” option (so you have an array inside the outer array). This can only be done by using a different syntax to define the Queue position.
Limit 限制队列长度
Sometimes too many effects get queued, for example when a user presses a button twice, or repeatedly enters and leaves a button hover area (and each time two effects are queued). This can cause a lot of distracting activity. To prevent this, we can add a “limit: n” option to the queue so no more than n effects are added to that ScopedQueue.
#1 and #2 will be added to the queue but #3 will not.
Effect.Queues
So what is Effect.Queues and why do we need it? Well, for each scope an instance of Effect.Scoped Queue? is created. That instance is stored in Effect.Queues. You can access it by using Effect.Queues.get(‘global’) which is the same as Effect.Queue because the default ‘global’ queue is saved into Effect.Queue by script.aculo.us. However when you need to access a scope other than ‘global, you need to fetch it using Effect.Queues.get(‘myscope’) before you can manipulate it.
我们可以从Effect.Queues得到我们创建的Queue。因为它们都保存在Effect.Queues中
了!
ScopedQueue is just an Enumerable object. You can retrieve the effects one by one and manipulate them. Let’s look at how we can ‘empty a queue’.
Or maybe you want to change the interval between the effects in a queue:
更多精彩细节?
请看http://wiki.script.aculo.us/scriptaculous/show/EffectQueues
Let’s examine how events in a queue occur: For a programmer a queue is an Array with events that are stacked on each other to be handled one by one. For example, a user hovers over a button with his cursor and then after half a second leaves the button area again. Two events have taken place, the mouseover and the mouseout. If you would handle the mouseover and the mouseout event takes place, it could disturb your current process. However you can’t just ignore the event, because then you will be stuck in the status that is established by the actions you have performed for mouseover. In this situation you could add the event to a queue and every time you’re done with processing an event, just check the queue for unprocessed events (and act accordingly).
How do Effects work and why do you need a Queue
The same happens when you are dealing with Effects and you face the situation where two effects can be called, both of which manipulate the same DOM object(s). script.aculo.us comes to the rescue with several techniques to manage your effects. To explain this further, we will show you how things work by example.
什么是queue? 为了解决对同一个元素触发多个处理效果时需要解决效果发生的先后顺序问题。通过Queue队列的形式将并行的效果按我们的先后顺序串行化。
Effect.Queue
The previous examples gave you an idea of the situations you could be facing without Queues. This must give you some motivation to find how Effect.Queue could improve your live and help you to manage your Effects.
Effect.Queue is an improved array of Effects (called Enumerable) that is global for the entire page. It gets created by extracting the global queue from Effect.Queues (we will discuss this later). So all effects you want to queue will be added to the ‘global’ queue. You might be wondering how to add an effect to the queue? Well it’s quite easy.
Effect.Queue是一个改进的Effects数组。此对象作用范围为页面全局可访问。
new Effect.SlideDown('test1'); new Effect.SlideUp('test1', { queue: 'end'});
So you see I have added an array containing an entry “queue:” with the value “end”. This means that the Effect will be inserted at the end of the “global” Queue. All effects are always added to the queue, however without a position like ‘end’ they are always executed parallel to the other effects.
如果没有queue:end,效果将并行的执行。
Remember that JavaScript is not multi-threaded, so blocks of code are executed together when they get parsed. This causes the effects to start in parallel if no queue is defined.
This works nicely, doesn’t it? But what happens when you queue all kinds of effects in different places? You could have lots of effects that you would like to queue but they don’t all relate to each other. This is where Effect.ScopedQueue comes in.
Basic Effect.ScopedQueue
As explained before, the default Queue is ‘global’. All effects are placed in the ‘global’ Queue unless you define a different scope. A scope is nothing more than grouping a set of Effects together in their own Queue. To do this, you need to pass an array instead of a string to the “queue:” option (so you have an array inside the outer array). This can only be done by using a different syntax to define the Queue position.
new Effect.SlideUp('menu', {queue: {position:'end', scope: 'menuxscope'} }); new Effect.SlideUp('bannerbig', {queue: {position:'end', scope: 'bannerscope'} }); new Effect.SlideDown('menu', {queue: {position: 'end', scope: 'menuxscope'} });
Limit 限制队列长度
Sometimes too many effects get queued, for example when a user presses a button twice, or repeatedly enters and leaves a button hover area (and each time two effects are queued). This can cause a lot of distracting activity. To prevent this, we can add a “limit: n” option to the queue so no more than n effects are added to that ScopedQueue.
new Effect.SlideDown('menu', {queue: {position:'end', scope: 'menuxscope', limit:2} }); // #1 new Effect.Highlight('menu', {queue: {position:'end', scope: 'menuxscope', limit:2} }); // #2 new Effect.SlideUp('menu', {queue: {position: 'end', scope: 'menuxscope', limit:2} }); // #3
#1 and #2 will be added to the queue but #3 will not.
Effect.Queues
So what is Effect.Queues and why do we need it? Well, for each scope an instance of Effect.Scoped Queue? is created. That instance is stored in Effect.Queues. You can access it by using Effect.Queues.get(‘global’) which is the same as Effect.Queue because the default ‘global’ queue is saved into Effect.Queue by script.aculo.us. However when you need to access a scope other than ‘global, you need to fetch it using Effect.Queues.get(‘myscope’) before you can manipulate it.
我们可以从Effect.Queues得到我们创建的Queue。因为它们都保存在Effect.Queues中
了!
var queue = Effect.Queues.get('myscope');
ScopedQueue is just an Enumerable object. You can retrieve the effects one by one and manipulate them. Let’s look at how we can ‘empty a queue’.
var queue = Effect.Queues.get('myscope'); queue.each(function(e) { e.cancel() });
Or maybe you want to change the interval between the effects in a queue:
Effect.Queues.get('myscope').interval = 100;
更多精彩细节?
请看http://wiki.script.aculo.us/scriptaculous/show/EffectQueues
发表评论
-
Ajax Typeahead
2014-08-28 15:59 3128https://github.com/pwarelis/Aja ... -
DWR 1.x 升级 到3 错误
2013-04-02 15:08 1224最近需要从1.X 升级到3,很多页面失效,查找错误原因是DWR ... -
HTML5 Canvas Charts 统计图
2012-06-10 23:05 9471RGraph: HTML5/Javascript charts ... -
jplayer 实战
2010-08-18 23:59 7285今天客户一个B2C服装类网上商城系统需要在网站里播放背景音乐。 ... -
rapid validation 验证 无效果
2010-04-30 16:46 1201rapid validation 验证 无效果 可能原因:编 ... -
使用豆瓣api查书的js
2008-09-20 14:33 4307jquery版 <!DOCTYPE html PUBLI ... -
Combination Effects 各种组合效果
2008-01-26 19:23 1405Effect.Drop Out Makes the elem ... -
Effect.Puff
2008-01-26 19:02 1161Gives the illusion of the eleme ... -
Effect.Fade
2008-01-26 18:59 1453Makes an element fade away and ... -
script.aculo.us---Effect.Appear
2008-01-26 18:56 1470Examples Effect.Appear('id_o ... -
script.aculo.us---Core Effects
2008-01-26 18:22 1303The six core effects Effect.Op ... -
script.aculo.us---Effect.Parallel
2008-01-26 18:10 1359This is a special effect to all ... -
script.aculo.us---Effect.Highlight
2008-01-26 17:59 1476所谓的高亮显示就在这里了! This effect Flas ... -
script.aculo.us---Effect.Move
2008-01-26 17:46 1254This effect moves an element. E ... -
script.aculo.us---Effect.Morph
2008-01-26 17:26 1287This effect changes the CSS pro ... -
script.aculo.us---Effect.Scale
2008-01-26 16:48 1260This effect changes an elements ... -
script.aculo.us---Effect.Opacity
2008-01-26 16:34 1277This effect changes an element’ ... -
webcalendar.js 错误fix
2007-12-10 22:59 1738webcalendar.js IE中报this.panel不存 ... -
prototype中文介绍
2007-11-11 23:56 2926$::Utility Methods<o:p> ... -
prototype手记 $
2007-09-26 00:37 1749$::Utility Methods<o:p>&l ...
相关推荐
An Optimistic Approach to Lock-Free FIFO Queues
M. L. Chaudhry编写的《First Course in Bulk Queues》,是Bulk Queue的一份很好的教程,在学排队论的时候可以拿来参考。
无锁队列的C实现方法;作为备份;希望对别人有帮助
Probability, Markov chains, queues and simulation: the mathematical basis of performance modeling BOOK
delphi threads queues
Laravel开发-queues 一组队列助手
225.Implement_stack_using_queues用队列实现栈【LeetCode单题讲解系列】
Implement a Stack using Two Queues with C++
Laravel官方文档讲解,该资料是一整套视频,需要逐个下载,Queues 队列
Simple job queues for Python.zip
Fast Priority Queues for Cached Memory.
Java Methods-Stacks and Queues.ppt
as gpus become larger and provide an increasing ...currently the HSA and copute unified device architecture specifications support concurrent kernel launches with the help of multiple command queues.
Java Methods-Heaps and Priority Queues.ppt
Dual queues cache replacement algorithm based on sequentiality detection
数据结构--C语言描述 Chapter03-Stacks-and-Queues英文课件
Object-C_使用Object-C实现的堆栈stacks+队列queues
Dyno Queues是一种使用提供任务队列的方法。 Dyno队列功能 基于时间的队列。 每个队列元素都有一个关联的时间戳,只有在该时间之后才会被轮询。 优先队列 没有严格的FIFO语义。 但是,在一个分片中,元素以FIFO的...
表、栈和队列 _ Lists, Stacks and Queues1
Constructing your own 地上爬梯好次 queues with GCD 初学者学习代码