1/** 2 * jquery.resizestop (and resizestart) 3 * by: Fatih Kadir Akın 4 * https://github.com/f/jquery.resizestop 5 * License is CC0, published to the public domain. 6 */ 7// Used by datepicker when position is top or bottom of the screen 8( function( $ ) { 9 'use strict'; 10 // Slice shortcut 11 var slice = Array.prototype.slice; 12 13 // Special event definition 14 $.extend( $.event.special, { 15 // resize stop special event. 16 resizestop: { 17 add: function( handle ) { 18 // shortcut to the event handler. 19 var handler = handle.handler; 20 21 // event modifying 22 $( this ).on( 'resize', function( e ) { 23 var _proxy; 24 // every resize event clears handler's timer. 25 // and every handler must have a timer. 26 clearTimeout( handler._timer ); 27 // change event type text. 28 e.type = 'resizestop'; 29 // push the "resize" event to the handler. 30 _proxy = $.proxy( handler, this, e ); 31 // if no resize event fired for a time that we decide, 32 // then it means its stopped. 33 handler._timer = setTimeout( _proxy, handle.data || 200 ); 34 } ); 35 } 36 }, 37 // resize start special event 38 resizestart: { 39 add: function( handle ) { 40 // shortcut to the event handler. 41 var handler = handle.handler; 42 43 // event modifying 44 $( this ).on( 'resize', function( e ) { 45 // every resize event clears handler's timer. 46 // and every handler must have a timer. 47 clearTimeout( handler._timer ); 48 // we suddenly fire the event, then we can put 49 // a flag with name _started knows if it's already fired. 50 if ( ! handler._started ) { 51 e.type = 'resizestart'; 52 handler.apply( this, arguments ); 53 // after firing the handler, put the flag with the value "true" 54 handler._started = true; 55 } 56 handler._timer = setTimeout( 57 $.proxy( function() { 58 // after a while, it will make the flag false. 59 handler._started = false; 60 }, this ), 61 handle.data || 300 62 ); 63 } ); 64 } 65 } 66 } ); 67 // binding and currying the shortcuts. 68 $.extend( $.fn, { 69 // $(window).resizestop instead of $(window).on('resizestop') 70 resizestop: function() { 71 // will push the "resizestop" argument at the beginning of arguments 72 $( this ).on.apply( this, [ 'resizestop' ].concat( slice.call( arguments ) ) ); 73 }, 74 // $(window).resizestart instead of $(window).on('resizestart') 75 resizestart: function() { 76 // will push the "resizestart" argument at the beginning of arguments 77 $( this ).on.apply( this, [ 'resizestart' ].concat( slice.call( arguments ) ) ); 78 } 79 } ); 80}( window.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.