1/* 2 * throttledresize: special jQuery event that happens at a reduced rate compared to "resize" 3 * 4 * latest version and complete README available on Github: 5 * https://github.com/louisremi/jquery-smartresize 6 * 7 * Copyright 2012 @louis_remi 8 * Licensed under the MIT license. 9 * 10 * This saved you an hour of work? 11 * Send me music http://www.amazon.co.uk/wishlist/HNTU0468LQON 12 */ 13(function($) { 14 15var $event = $.event, 16 $special, 17 dummy = {_:0}, 18 frame = 0, 19 wasResized, animRunning; 20 21$special = $event.special.throttledresize = { 22 setup: function() { 23 $( this ).on( "resize", $special.handler ); 24 }, 25 teardown: function() { 26 $( this ).off( "resize", $special.handler ); 27 }, 28 handler: function( event, execAsap ) { 29 // Save the context 30 var context = this, 31 args = arguments; 32 33 wasResized = true; 34 35 if ( !animRunning ) { 36 setInterval(function(){ 37 frame++; 38 39 if ( frame > $special.threshold && wasResized || execAsap ) { 40 // set correct event type 41 event.type = "throttledresize"; 42 $event.dispatch.apply( context, args ); 43 wasResized = false; 44 frame = 0; 45 } 46 if ( frame > 9 ) { 47 $(dummy).stop(); 48 animRunning = false; 49 frame = 0; 50 } 51 }, 30); 52 animRunning = true; 53 } 54 }, 55 threshold: 0 56}; 57 58})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.