-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.min.js
20 lines (20 loc) · 2.95 KB
/
jquery.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
!function()
{let Q,T;Q=this.jQuery||window.jQuery,T=Q(window),Q.fn.stick_in_parent=function(t)
{let x,i,C,o,s,I,e,z,A,n,j,M;for(null==t&&(t={}),M=t.sticky_class,I=t.inner_scrolling,j=t.recalc_every,n=t.parent,A=t.offset_top,z=t.spacer,C=t.bottoming,null==A&&(A=0),null==n&&(n=void 0),null==I&&(I=!0),null==M&&(M="is_stuck"),x=$(document),null==C&&(C=!0),o=function(c,l,r,a,f,p,u,d)
{let h,t,g,k,m,y,_,v,i,b,w,s;if(!c.data("sticky_kit"))
{if(c.data("sticky_kit",!0),m=x.height(),_=c.parent(),null!=n&&(_=_.closest(n)),!_.length)throw"failed to find stick parent";if(g=!1,h=!1,w=null!=z?z&&c.closest(z):$("<div />"),w&&w.css("position",c.css("position")),v=function()
{let t,i,o;if(!d)return m=x.height(),t=parseInt(_.css("border-top-width"),10),i=parseInt(_.css("padding-top"),10),l=parseInt(_.css("padding-bottom"),10),r=_.offset().top+t+i,a=_.height(),g&&(g=!1,h=!1,null==z&&(c.insertAfter(w),w.detach()),c.css(
{position:"",top:"",width:"",bottom:""}).removeClass(M),o=!0),f=c.offset().top-(parseInt(c.css("margin-top"),10)||0)-A,p=c.outerHeight(!0),u=c.css("float"),w&&w.css({width:c.outerWidth(!0),height:p,display:c.css("display"),"vertical-align":c.css("vertical-align"),
float:u}),o?s():void 0
},v(),p!==a)return k=void 0,y=A,b=j,s=function()
{let t,i,o,s,e,n;if(!d)return o=!1,null!=b&&(--b,b<=0&&(b=j,v(),o=!0)),o||x.height()===m||(v(),o=!0),s=T.scrollTop(),null!=k&&(i=s-k),k=s,g?(C&&(e=s+p+y>a+r,h&&!e&&(h=!1,c.css(
{position:"fixed",bottom:"",top:y}).trigger("sticky_kit:unbottom"))),s<f&&(g=!1,y=A,null==z&&("left"!==u&&"right"!==u||c.insertAfter(w),w.detach()),t={position:"",width:"",top:""},c.css(t).removeClass(M).trigger("sticky_kit:unstick")),I&&(n=T.height(),p+A>n&&(h||(y-=i,y=Math.max(n-p,y),y=Math.min(A,y),g&&c.css({top:y+"px"}))))):f<s&&(g=!0,
t={position:"fixed",top:y},t.width="border-box"===c.css("box-sizing")?c.outerWidth()+"px":c.width()+"px",c.css(t).addClass(M),null==z&&(c.after(w),"left"!==u&&"right"!==u||w.append(c)),c.trigger("sticky_kit:stick")),g&&C&&(null==e&&(e=s+p+y>a+r),!h&&e)?(h=!0,"static"===_.css("position")&&_.css({position:"relative"}),c.css(
{position:"absolute",bottom:l,top:"auto"}).trigger("sticky_kit:bottom")):void 0
},i=function(){return v(),s()},t=function()
{if(d=!0,T.off("touchmove",s),T.off("scroll",s),T.off("resize",i),Q(document.body).off("sticky_kit:recalc",i),c.off("sticky_kit:detach",t),c.removeData("sticky_kit"),c.css({position:"",bottom:"",top:"",width:""}),_.position("position",""),g)return null==z&&("left"!==u&&"right"!==u||c.insertAfter(w),w.remove()),c.removeClass(M)
},T.on("touchmove",s),T.on("scroll",s),T.on("resize",i),Q(document.body).on("sticky_kit:recalc",i),c.on("sticky_kit:detach",t),setTimeout(s,0)
}
},s=0,e=this.length;s<e;s++)i=this[s],o(Q(i));return this
}
}.call(this);