1(function($){ 2 $.fn.tmStickUp=function(options){ 3 4 var getOptions = { 5 correctionSelector: $('.correctionSelector') 6 , listenSelector: $('.listenSelector') 7 , active: false 8 , pseudo: true 9 } 10 $.extend(getOptions, options); 11 12 var 13 _this = $(this) 14 , _window = $(window) 15 , _document = $(document) 16 , thisOffsetTop = 0 17 , thisOuterHeight = 0 18 , thisMarginTop = 0 19 , thisPaddingTop = 0 20 , documentScroll = 0 21 , pseudoBlock 22 , lastScrollValue = 0 23 , scrollDir = '' 24 , tmpScrolled 25 ; 26 27 if (_this.length != 0) { 28 init(); 29 } 30 31 function init(){ 32 thisOffsetTop = parseInt(_this.offset().top); 33 thisMarginTop = parseInt(_this.css("margin-top")); 34 thisOuterHeight = parseInt(_this.outerHeight(true)); 35 36 if(getOptions.pseudo){ 37 $('<div class="pseudoStickyBlock"></div>').insertAfter(_this); 38 pseudoBlock = $('.pseudoStickyBlock'); 39 pseudoBlock.css({"position":"relative", "display":"block"}); 40 } 41 42 if(getOptions.active){ 43 addEventsFunction(); 44 } 45 }//end init 46 47 function addEventsFunction(){ 48 _document.on('scroll', function() { 49 tmpScrolled = $(this).scrollTop(); 50 if (tmpScrolled > lastScrollValue){ 51 scrollDir = 'down'; 52 } else { 53 scrollDir = 'up'; 54 } 55 lastScrollValue = tmpScrolled; 56 57 if(getOptions.correctionSelector.length != 0){ 58 correctionValue = getOptions.correctionSelector.outerHeight(true); 59 }else{ 60 correctionValue = 0; 61 } 62 63 documentScroll = parseInt(_window.scrollTop()); 64 if(thisOffsetTop - correctionValue < documentScroll){ 65 _this.addClass('isStuck'); 66 getOptions.listenSelector.addClass('isStuck'); 67 if(getOptions.pseudo){ 68 _this.css({position:"fixed", top:correctionValue}); 69 pseudoBlock.css({"height":thisOuterHeight}); 70 }else{ 71 _this.css({position:"fixed", top:correctionValue}); 72 } 73 }else{ 74 _this.removeClass('isStuck'); 75 getOptions.listenSelector.removeClass('isStuck'); 76 if(getOptions.pseudo){ 77 _this.css({position:"relative", top:0}); 78 pseudoBlock.css({"height":0}); 79 }else{ 80 _this.css({position:"absolute", top:0}); 81 } 82 } 83 }).trigger('scroll'); 84 85 _document.on("resize", function() { 86 if(_this.hasClass('isStuck')){ 87 if( thisOffsetTop != parseInt(pseudoBlock.offset().top) ) thisOffsetTop = parseInt(pseudoBlock.offset().top); 88 } else { 89 if( thisOffsetTop != parseInt(_this.offset().top) ) thisOffsetTop = parseInt(_this.offset().top); 90 } 91 }) 92 } 93 }//end tmStickUp function 94})(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.