1/** 2 * Plugin Name: jQuery Essentials Sticky 3 * Version: 1.5 4 * Date: 01-10-2019 5 * 6 * Usage: 7 jQuery(outerContainer).esSticky({ 8 innerContainer: ".sticky-container-in", 9 minFixed: true, 10 minFixedWidth: 768, 11 maxFixed: false, 12 maxFixedWidth: 767, 13 scrollContainer: window, 14 perfectScroll: false 15 }); 16 * 17**/ 18 19(function ( jQuery ) { 20 21 jQuery.fn.esSticky= function( options ) { 22 var outerContainer = jQuery(this); 23 var settings = jQuery.extend({ 24 innerContainer: ".sticky-container-in", 25 minFixed: true, 26 minFixedWidth: 768, 27 maxFixed: false, 28 maxFixedWidth: 767, 29 scrollContainer: window, 30 perfectScroll: false 31 }, options); 32 33 function renderEsSticky(){ 34 if(settings.perfectScroll){ 35 var windowWidth = jQuery(settings.scrollContainer).width(); 36 } else { 37 var windowWidth = jQuery(window).width(); 38 } 39 40 if((!settings.minFixed && !settings.maxFixed) || (settings.minFixed && (windowWidth > settings.minFixedWidth)) || (settings.maxFixed && (windowWidth <= settings.maxFixedWidth))){ 41 var container = outerContainer; 42 var fixedPosition = 0; 43 container.each(function(){ 44 45 var containerHeight = jQuery(this).height(); 46 47 if(settings.perfectScroll){ 48 var windowScroll = jQuery(settings.scrollContainer).scrollTop(); 49 var containerPosition = jQuery(this).position().top; 50 var containerIn = jQuery(this).find(settings.innerContainer); 51 if(containerPosition < 0){ 52 containerIn.addClass('fixed').css('top',fixedPosition+'px'); 53 fixedPosition = fixedPosition+containerHeight; 54 } else { 55 containerIn.removeClass('fixed').css('top','0px'); 56 } 57 } else { 58 var windowScroll = jQuery(window).scrollTop(); 59 var containerPosition = jQuery(this).offset().top; 60 var containerIn = jQuery(this).find(settings.innerContainer); 61 if((windowScroll+fixedPosition) < containerPosition){ 62 containerIn.removeClass('fixed').css('top','0px'); 63 } else { 64 containerIn.addClass('fixed').css('top',fixedPosition+'px'); 65 fixedPosition = fixedPosition+containerHeight; 66 } 67 } 68 69 }); 70 } 71 } 72 73 function resizeSticky(){ 74 if(settings.perfectScroll){ 75 var windowWidth = jQuery(settings.scrollContainer).width(); 76 } else { 77 var windowWidth = jQuery(window).width(); 78 } 79 if(!settings.minFixed || (settings.minFixed && (windowWidth > settings.minFixedWidth))){ 80 var container = outerContainer; 81 container.each(function(){ 82 var containerIn = jQuery(this).find(settings.innerContainer); 83 var containerInHeight = containerIn.outerHeight(); 84 jQuery(this).height(containerInHeight); 85 }); 86 } 87 } 88 89 jQuery(window).on('load',function(){ 90 resizeSticky(); 91 renderEsSticky(); 92 }); 93 94 jQuery(window).on('resize',function(){ 95 resizeSticky(); 96 renderEsSticky(); 97 }); 98 99 if(settings.perfectScroll){ 100 jQuery(settings.scrollContainer).on('ps-scroll-y',function(){ 101 renderEsSticky(); 102 }); 103 } else { 104 jQuery(settings.scrollContainer).on('scroll',function(){ 105 renderEsSticky(); 106 }); 107 } 108 109 }; 110 111}( 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.