LocalCDN-Firefox-Chrome-Brave/resources/semantic-ui/2.5.0/components/sticky.min.jsm

1 line
12 KiB
JavaScript
Raw Normal View History

2022-10-07 06:16:13 +02:00
!function(T,w,B,P){"use strict";w=void 0!==w&&w.Math==Math?w:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),T.fn.sticky=function(b){var v,e=T(this),x=e.selector||"",S=(new Date).getTime(),C=[],y=b,k="string"==typeof y,z=[].slice.call(arguments,1);return e.each(function(){var n,i,e,t,m=T.isPlainObject(b)?T.extend(!0,{},T.fn.sticky.settings,b):T.extend({},T.fn.sticky.settings),o=m.className,s=m.namespace,r=m.error,c="."+s,l="module-"+s,a=T(this),f=T(w),u=T(m.scrollContext),h=(a.selector,a.data(l)),d=w.requestAnimationFrame||w.mozRequestAnimationFrame||w.webkitRequestAnimationFrame||w.msRequestAnimationFrame||function(e){setTimeout(e,0)},g=this,p={initialize:function(){p.determineContainer(),p.determineContext(),p.verbose("Initializing sticky",m,n),p.save.positions(),p.checkErrors(),p.bind.events(),m.observeChanges&&p.observeChanges(),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),h=p,a.data(l,p)},destroy:function(){p.verbose("Destroying previous instance"),p.reset(),e&&e.disconnect(),t&&t.disconnect(),f.off("load"+c,p.event.load).off("resize"+c,p.event.resize),u.off("scrollchange"+c,p.event.scrollchange),a.removeData(l)},observeChanges:function(){"MutationObserver"in w&&(e=new MutationObserver(p.event.documentChanged),t=new MutationObserver(p.event.changed),e.observe(B,{childList:!0,subtree:!0}),t.observe(g,{childList:!0,subtree:!0}),t.observe(i[0],{childList:!0,subtree:!0}),p.debug("Setting up mutation observer",t))},determineContainer:function(){n=m.container?T(m.container):a.offsetParent()},determineContext:function(){0!==(i=m.context?T(m.context):n).length||p.error(r.invalidContext,m.context,a)},checkErrors:function(){if(p.is.hidden()&&p.error(r.visible,a),p.cache.element.height>p.cache.context.height)return p.reset(),void p.error(r.elementSize,a)},bind:{events:function(){f.on("load"+c,p.event.load).on("resize"+c,p.event.resize),u.off("scroll"+c).on("scroll"+c,p.event.scroll).on("scrollchange"+c,p.event.scrollchange)}},event:{changed:function(e){clearTimeout(p.timer),p.timer=setTimeout(function(){p.verbose("DOM tree modified, updating sticky menu",e),p.refresh()},100)},documentChanged:function(e){[].forEach.call(e,function(e){e.removedNodes&&[].forEach.call(e.removedNodes,function(e){(e==g||0<T(e).find(g).length)&&(p.debug("Element removed from DOM, tearing down events"),p.destroy())})})},load:function(){p.verbose("Page contents finished loading"),d(p.refresh)},resize:function(){p.verbose("Window resized"),d(p.refresh)},scroll:function(){d(function(){u.triggerHandler("scrollchange"+c,u.scrollTop())})},scrollchange:function(e,t){p.stick(t),m.onScroll.call(g)}},refresh:function(e){p.reset(),m.context||p.determineContext(),e&&p.determineContainer(),p.save.positions(),p.stick(),m.onReposition.call(g)},supports:{sticky:function(){var e=T("<div/>");e[0];return e.addClass(o.supported),e.css("position").match("sticky")}},save:{lastScroll:function(e){p.lastScroll=e},elementScroll:function(e){p.elementScroll=e},positions:function(){var e={height:u.height()},t={margin:{top:parseInt(a.css("margin-top"),10),bottom:parseInt(a.css("margin-bottom"),10)},offset:a.offset(),width:a.outerWidth(),height:a.outerHeight()},o={offset:i.offset(),height:i.outerHeight()};n.outerHeight();p.is.standardScroll()||(p.debug("Non-standard scroll. Removing scroll offset from element offset"),e.top=u.scrollTop(),e.left=u.scrollLeft(),t.offset.top+=e.top,o.offset.top+=e.top,t.offset.left+=e.left,o.offset.left+=e.left),p.cache={fits:t.height+m.offset<=e.height,sameHeight:t.height==o.height,scrollContext:{height:e.height},element:{margin:t.margin,top:t.offset.top-t.margin.top,left:t.offset.left,width:t.width,height:t.height,bottom:t.offset.top+t.height},context:{top:o.offset.top,height:o.height,bottom:o.offset.top+o.height}},p.set.containerSize(),p.stick(),p.debug("Caching element positions",p.cache)}},get:{direction:function(e){var t="down";return e=e||u.scrollTop(),p.lastScroll!==P&&(p.lastScroll<e?t="down":p.lastScroll>e&&(t="up")),t},scrollChange:function(e){return e=e||u.scrollTop(),p.lastScr