1(function($) { 2 3 var $event = $.event, 4 $special, 5 resizeTimeout; 6 7 $special = $event.special.debouncedresize = { 8 setup: function() { 9 $( this ).on( "resize", $special.handler ); 10 }, 11 teardown: function() { 12 $( this ).off( "resize", $special.handler ); 13 }, 14 handler: function( event, execAsap ) { 15 // Save the context 16 var context = this, 17 args = arguments, 18 dispatch = function() { 19 // set correct event type 20 event.type = "debouncedresize"; 21 $event.dispatch.apply( context, args ); 22 }; 23 24 if ( resizeTimeout ) { 25 clearTimeout( resizeTimeout ); 26 } 27 28 execAsap ? 29 dispatch() : 30 resizeTimeout = setTimeout( dispatch, $special.threshold ); 31 }, 32 threshold: 150 33 }; 34 35})(jQuery); 36 37 38/* 39 * throttledresize: special jQuery event that happens at a reduced rate compared to "resize" 40 * 41 * latest version and complete README available on Github: 42 * https://github.com/louisremi/jquery-smartresize 43 * 44 * Copyright 2012 @louis_remi 45 * Licensed under the MIT license. 46 * 47 * This saved you an hour of work? 48 * Send me music http://www.amazon.co.uk/wishlist/HNTU0468LQON 49 */ 50(function($) { 51 52var $event = $.event, 53 $special, 54 dummy = {_:0}, 55 frame = 0, 56 wasResized, animRunning; 57 58$special = $event.special.throttledresize = { 59 setup: function() { 60 $( this ).on( "resize", $special.handler ); 61 }, 62 teardown: function() { 63 $( this ).off( "resize", $special.handler ); 64 }, 65 handler: function( event, execAsap ) { 66 // Save the context 67 var context = this, 68 args = arguments; 69 70 wasResized = true; 71 72 if ( !animRunning ) { 73 setInterval(function(){ 74 frame++; 75 76 if ( frame > $special.threshold && wasResized || execAsap ) { 77 // set correct event type 78 event.type = "throttledresize"; 79 $event.dispatch.apply( context, args ); 80 wasResized = false; 81 frame = 0; 82 } 83 if ( frame > 9 ) { 84 $(dummy).stop(); 85 animRunning = false; 86 frame = 0; 87 } 88 }, 30); 89 animRunning = true; 90 } 91 }, 92 threshold: 0 93}; 94 95})(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.