mirror of https://github.com/metafizzy/isotope
Filter & sort magical layouts
http://isotope.metafizzy.co
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
15 years ago
|
/*!
|
||
|
* smartresize: debounced resize event for jQuery
|
||
|
* http://github.com/lrbabe/jquery-smartresize
|
||
|
*
|
||
|
* Copyright (c) 2009 Louis-Remi Babe
|
||
|
* Licensed under the GPL license.
|
||
|
* http://docs.jquery.com/License
|
||
|
*
|
||
|
*/
|
||
|
(function($){
|
||
|
|
||
|
var $event = $.event,
|
||
|
resizeTimeout;
|
||
|
|
||
|
$event.special.smartresize = {
|
||
|
setup: function() {
|
||
|
$(this).bind( "resize", $event.special.smartresize.handler );
|
||
|
},
|
||
|
teardown: function() {
|
||
|
$(this).unbind( "resize", $event.special.smartresize.handler );
|
||
|
},
|
||
|
handler: function( event, execAsap ) {
|
||
|
// Save the context
|
||
|
var context = this,
|
||
|
args = arguments;
|
||
|
|
||
|
// set correct event type
|
||
|
event.type = "smartresize";
|
||
|
|
||
|
if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
|
||
|
resizeTimeout = setTimeout(function() {
|
||
|
jQuery.event.handle.apply( context, args );
|
||
|
}, execAsap === "execAsap"? 0 : 100 );
|
||
|
}
|
||
|
};
|
||
|
|
||
|
$.fn.smartresize = function( fn ) {
|
||
|
return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
|
||
|
};
|
||
|
|
||
|
})( jQuery );
|