Sha256: bc2f835baa1e34fe20e4b8072c92681f91634e584ef93dc59513597fd9214687
Contents?: true
Size: 917 Bytes
Versions: 4
Compression:
Stored size: 917 Bytes
Contents
//Smart resizer a la paul irish (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; } if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; }; // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; /* usage: $(window).smartresize(function(){ [code that takes it easy...] }); */ })(jQuery,'smartresize');
Version data entries
4 entries across 4 versions & 1 rubygems