I like this. I don't particularly care what we call it.

Too late for 1.7, naturally, but perhaps 1.7.1 or 1.8...

Cheers,
Andrew

On Apr 23, 2010, at 10:15 AM, Mislav Marohnić wrote:

> On Fri, Apr 23, 2010 at 15:00, Titi Alailima <tigreti...@gmail.com> wrote:
> 
> "debounce" is a technical term, and it refers to the very case that you are 
> trying to handle.
> 
> Thanks, Titi, for the insightful explanation.
> 
> Here is how I would implement a real throttle method:
> 
>   Function.prototype.throttle = function(t) {
>     var timeout, scope, args, fn = this, tick = function() {
>       fn.apply(scope, args)
>       timeout = null
>     }
>     return function() {
>       scope = this
>       args = arguments
>       if (!timeout) timeout = setTimeout(tick, t)
>     }
>   }
> 
> It's really just a twist on the original method in a way that it fires every 
> `t` milliseconds, and calls in-between do nothing except update the scope and 
> arguments. If the first argument is an event object, you definitely want the 
> last event object of the series rather than the first one.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Prototype: Core" group.
> To post to this group, send email to prototype-core@googlegroups.com
> To unsubscribe from this group, send email to 
> prototype-core-unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/prototype-core?hl=en

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en

Reply via email to