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