jon.whitcraft
8 Jan 2007, 9:43 AM
So while coding today i need a buffered Listener but I wanted it to be managed so that way i didn't have to deal with the event handeling of different browsers.
I came up with this patch Element.js
/**
* Appends a managed listener to this element that is buffered. If the event is triggered more than once
* in the specified time-frame, only the last one actually fires.
* @param {String} eventName The type of event to listen for
* @param {Function} handler The method the event invokes
* @param {Object} scope (optional) The scope (this object) for the handler
* @param {Number} millis (optional) The number of milliseconds to buffer (defaults to 250)
* @return {Function} The wrapped function that was created (can be used to remove the listener)
*/
bufferedManagedListener : function(eventName, fn, scope, millis){
var task = new YAHOO.ext.util.DelayedTask();
scope = scope || this;
var newFn = function(){
task.delay(millis || 250, fn, scope, Array.prototype.slice.call(arguments, 0));
}
this.mon(eventName, newFn);
return newFn;
},
I have created a patch file for this if Jack likes it i can send it his way to just put in on the svn server Just let me know.
I came up with this patch Element.js
/**
* Appends a managed listener to this element that is buffered. If the event is triggered more than once
* in the specified time-frame, only the last one actually fires.
* @param {String} eventName The type of event to listen for
* @param {Function} handler The method the event invokes
* @param {Object} scope (optional) The scope (this object) for the handler
* @param {Number} millis (optional) The number of milliseconds to buffer (defaults to 250)
* @return {Function} The wrapped function that was created (can be used to remove the listener)
*/
bufferedManagedListener : function(eventName, fn, scope, millis){
var task = new YAHOO.ext.util.DelayedTask();
scope = scope || this;
var newFn = function(){
task.delay(millis || 250, fn, scope, Array.prototype.slice.call(arguments, 0));
}
this.mon(eventName, newFn);
return newFn;
},
I have created a patch file for this if Jack likes it i can send it his way to just put in on the svn server Just let me know.