2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
|
function generateStickyDebounce(s,n,a){var o;return function(){var t=this,e=arguments,i=a&&!o;clearTimeout(o),o=setTimeout(function(){o=null,a||s.apply(t,e)},n),i&&s.apply(t,e)}}!function(T,M,E){var e=function(t,e){var s=0,n=0,a="",o=0,r=!1,l=!1,c=!1,p=!1,d=0,m=0,h=0,f=0,u=0,g=T(),i=T("body"),b=0,v=0,k=0,y=T(t).clone().css({visibility:"hidden",display:"none"}).attr({id:"sticky-placeholder",itemtype:null,itemscope:null}),w=T(),C={top:0,bottom:0,custom:[]},I={scrollHide:!1,lazyHeight:0,topMargin:"auto",keepInWrapper:!1,wrapperSelector:"",zIndex:100,namespaceClass:"stuckElement",fixedClass:"isStuck",disableOn:function(){return!0},transition:"none"},H=function(){var t=0<jQuery("#wpadminbar").length&&"fixed"==jQuery("#wpadminbar").css("position")?jQuery("#wpadminbar").outerHeight():0;return"auto"===I.topMargin?parseInt(t+g.css("marginTop")):isNaN(I.topMargin)&&0<I.topMargin.search("px")?parseInt(t+I.topMargin.replace("px","")):isNaN(parseInt(I.topMargin))?0:parseInt(t+I.topMargin)},x=function(){y.hide().removeClass(I.fixedClass).removeClass("sticky-navigation-transition"),g.removeClass(I.fixedClass).css({"max-width":"","margin-top":"","margin-left":"","margin-right":"",position:"",top:"",left:"",right:"",bottom:"",width:"",opacity:"",height:"",overflow:"","-webkit-transform":"","-ms-transform":"",transform:"","-webkit-transition":"","-ms-transition":"",transition:"",visibility:""}).removeClass("sticky-navigation-transition").removeClass("navigation-transition"),"sticky-navigation"===g.attr("id")&&g.attr("id","site-navigation"),c=l=r=!1,g.trigger("stickUp:unStick")},S=function(t){y.show().addClass(I.fixedClass);var e=y.offsetParent();if(t){g.css({position:"absolute"});var i=w.offset().top+w.outerHeight()-e.offset().top-m-parseInt(w.css("paddingBottom"))}g.css({position:"absolute",marginTop:v,bottom:"",left:y.position().left,top:t?i:g.offset().top-e.offset().top-v}),g.trigger("stickUp:holdIt")},U=function(t){if(I.disableOn()){if(p&&(p=!1),!I.keepInWrapper||w.is(":visible")){if(n=T(t.target).scrollTop(),a=s<=n?"down":"up",o=Math.abs(s-n),h=T(M).outerHeight(),n+h,s=n,f=g.offset().top,d=parseInt(g.outerHeight()+v)+parseInt(g.css("marginBottom")),r||c||l||(parseInt(g.outerHeight(!0)),l||c?(C.top=parseInt(y.offset().top),parseInt(g.offset().left)+5):C.top=parseInt(g.offset().top)),m=parseInt(g.outerHeight())+parseInt(g.css("margin-bottom"))+v,I.keepInWrapper?C.bottom=w.offset().top+w.outerHeight()-parseInt(w.css("paddingBottom")):C.bottom=T(E).outerHeight(),u=g.offset().top+m,k=I.scrollHide?d+I.lazyHeight:I.lazyHeight,"none"!==I.transition&&(b=2*g.outerHeight()),v=null!==I.topMargin?H():0,r&&v!==g.css("margin-top")&&g.css("margin-top",v),(!r&&!l&&n>=C.top-v+k+b||l&&c&&n<=f-v+k)&&(!function(){r=!0,"fade"==I.transition&&g.hide(),("slide"==I.transition||I.scrollHide)&&g.css({height:"0",overflow:"hidden",visibility:"hidden"}),y.show().addClass(I.fixedClass),"left"!=g.css("float")&&"right"!=g.css("float")||(y.css("float",g.css("float")),y.attr("style",y.attr("style")+"width:auto !important")),"slide"==I.transition&&"block"==y.css("display")&&g.css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)","-webkit-transition":"transform 300ms ease-in-out","-ms-transition":"transform 300ms ease-in-out",transition:"transform 300ms ease-in-out"}),g.addClass(I.fixedClass),"site-navigation"===g.attr("id")&&g.attr("id","sticky-navigation");var t=-k;g.css({"margin-top":v,position:"fixed",top:t+"px",left:"",right:"",bottom:""}),g.trigger("stickUp:stickIt"),"fade"==I.transition&&g.fadeIn(300),"slide"==I.transition&&g.one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",function(t){g.css({visibility:"",height:"",overflow:""}),setTimeout(function(){g.css({"-webkit-transform":"translateY(0)","-ms-transform":"translateY(0)",transform:"translateY(0)"})},10)}),I.scrollHide&&g.css({height:"",overflow:"",visibility:""})}(),c=l=!(r=!0)),r&&!l&&n>=C.top-v+k+g.outerHeight()/2&&(y.addClass("sticky-navigation-transition"),g.addClass("sticky-navigation-transition")),I.keepInWrapp
|