|
|
/* * # Semantic UI * https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
* * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* */ !function(e,o,t,n){e.fn.visibility=function(s){var i,c=e(this),r=c.selector||"",a=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,m=[].slice.call(arguments,1);return c.each(function(){var c,b=e.extend(!0,{},e.fn.visibility.settings,s),p=b.className,f=b.namespace,g=(b.error,"."+f),v="module-"+f,h=e(o),P=e(this),V=e(b.context),x=(P.offsetParent(),P.selector||"",P.data(v)),y=o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||o.msRequestAnimationFrame||function(e){setTimeout(e,0)},R=this;c={initialize:function(){c.verbose("Initializing visibility",b),c.setup.cache(),c.save.position(),c.bindEvents(),c.instantiate(),"image"==b.type&&c.setup.image(),"fixed"==b.type&&c.setup.fixed(),y(c.checkVisibility)},instantiate:function(){c.verbose("Storing instance of module",c),x=c,P.data(v,c)},destroy:function(){c.verbose("Destroying previous module"),P.off(g).removeData(v)},bindEvents:function(){c.verbose("Binding visibility events to scroll and resize"),h.on("resize"+g,c.event.refresh),V.on("scroll"+g,c.event.scroll)},event:{refresh:function(){y(c.refresh)},scroll:function(){c.verbose("Scroll position changed"),b.throttle?(clearTimeout(c.timer),c.timer=setTimeout(c.checkVisibility,b.throttle)):y(c.checkVisibility)}},precache:function(o,n){o instanceof Array||(o=[o]);for(var s=o.length,i=0,c=[],r=t.createElement("img"),a=function(){i++,i>=o.length&&e.isFunction(n)&&n()};s--;)r=t.createElement("img"),r.onload=a,r.onerror=a,r.src=o[s],c.push(r)},setup:{cache:function(){c.cache={occurred:{},screen:{},element:{}}},image:function(){var e=P.data("src");e&&(c.verbose("Lazy loading image",e),c.topVisible(function(){c.precache(e,function(){c.set.image(e),b.onTopVisible=!1})}))},fixed:function(){c.verbose("Setting up fixed on element pass"),P.visibility({once:!1,continuous:!1,onTopPassed:function(){P.addClass(p.fixed).css({position:"fixed",top:b.offset+"px"}),b.animation&&e.fn.transition!==n&&P.transition(b.transition,b.duration)},onTopPassedReverse:function(){P.removeClass(p.fixed).css({position:"",top:""})}})}},set:{image:function(o){var t=c.cache.screen.bottom<c.cache.element.top;P.attr("src",o),t?(c.verbose("Image outside browser, avoiding animation"),P.show()):b.transition&&e.fn.transition!==n?P.transition(b.transition,b.duration):P.fadeIn(b.duration)}},refresh:function(){c.debug("Refreshing constants (element width/height)"),c.reset(),c.save.position(),c.checkVisibility(),e.proxy(b.onRefresh,R)()},reset:function(){c.verbose("Reseting all cached values"),e.isPlainObject(c.cache)&&(c.cache.screen={},c.cache.element={})},checkVisibility:function(){c.verbose("Checking visibility of element",c.cache.element),c.save.scroll(),c.save.direction(),c.save.screenCalculations(),c.save.elementCalculations(),c.passed(),c.passingReverse(),c.topVisibleReverse(),c.bottomVisibleReverse(),c.topPassedReverse(),c.bottomPassedReverse(),c.passing(),c.topVisible(),c.bottomVisible(),c.topPassed(),c.bottomPassed()},passed:function(o,t){var s=c.get.elementCalculations();if(o!==n&&t!==n)b.onPassed[o]=t;else{if(o!==n)return c.get.pixelsPassed(o)>s.pixelsPassed;s.passing&&e.each(b.onPassed,function(e,o){s.bottomVisible||s.pixelsPassed>c.get.pixelsPassed(e)?c.execute(o,e):b.once||c.remove.occurred(o)})}},passing:function(e){var o=c.get.elementCalculations(),t=e||b.onPassing,s="passing";return e&&(c.debug("Adding callback for passing",e),b.onPassing=e),o.passing?c.execute(t,s):b.once||c.remove.occurred(s),e!==n?o.passing:void 0},topVisible:function(e){var o=c.get.elementCalculations(),t=e||b.onTopVisible,s="topVisible";return e&&(c.debug("Adding callback for top visible",e),b.onTopVisible=e),o.topVisible?c.execute(t,s):b.once||c.remove.occurred(s),e===n?o.topVisible:void 0},bottomVisible:function(e){var o=c.get.elementCalculations(),t=e||b.onBottomVisible,s="bottomVisible";return e&&(c.debug("Adding callback for bottom visible",e),b.onBottomVisible=e),o.bottomVisible?c.execute(t,s):b.once||c.remove.occurred(s),e===n?o.bottomVisible:void 0},topPassed:function(e){var o=c.get.elementCalculations(),t=e||b.onTopPassed,s="topPassed
|