|
|
/*! * # Semantic UI 1.11.4 - Visibility * http://github.com/semantic-org/semantic-ui/
* * * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* */ !function(e,t,o,n){"use strict";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,g=e.isPlainObject(s)?e.extend(!0,{},e.fn.visibility.settings,s):e.extend({},e.fn.visibility.settings),p=g.className,v=g.namespace,f=g.error,h="."+v,P="module-"+v,V=e(t),C=e(this),y=e(g.context),R=(C.offsetParent(),C.selector||"",C.data(P)),x=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},T=this;b={initialize:function(){b.debug("Initializing",g),b.setup.cache(),b.save.position(),b.should.trackChanges()&&(b.bind.events(),"image"==g.type&&b.setup.image(),"fixed"==g.type&&b.setup.fixed()),g.initialCheck&&b.checkVisibility(),g.observeChanges&&b.observeChanges(),b.instantiate()},instantiate:function(){b.debug("Storing instance",b),C.data(P,b),R=b},destroy:function(){b.verbose("Destroying previous module"),C.off(h).removeData(P),V.off("resize"+h,b.event.refresh),y.off("scroll"+h,b.event.scroll)},observeChanges:function(){y[0];"MutationObserver"in t&&(c=new MutationObserver(function(){b.verbose("DOM tree modified, updating visibility calculations"),b.refresh()}),c.observe(T,{childList:!0,subtree:!0}),b.debug("Setting up mutation observer",c))},bind:{events:function(){b.verbose("Binding visibility events to scroll and resize"),V.on("resize"+h,b.event.refresh),y.on("scroll"+h,b.event.scroll)}},event:{refresh:function(){x(b.refresh)},scroll:function(){b.verbose("Scroll position changed"),g.throttle?(clearTimeout(b.timer),b.timer=setTimeout(function(){b.checkVisibility()},g.throttle)):x(function(){b.checkVisibility()})}},precache:function(t,n){t instanceof Array||(t=[t]);for(var s=t.length,i=0,c=[],r=o.createElement("img"),a=function(){i++,i>=t.length&&e.isFunction(n)&&n()};s--;)r=o.createElement("img"),r.onload=a,r.onerror=a,r.src=t[s],c.push(r)},should:{trackChanges:function(){return d&&m.length>0?(b.debug("One time query, no need to bind events"),!1):(b.debug("Callbacks being attached"),!0)}},setup:{cache:function(){b.cache={occurred:{},screen:{},element:{}}},image:function(){var e=C.data("src");e&&(b.verbose("Lazy loading image",e),g.observeChanges=!1,b.topVisible(function(){b.debug("Image top visible",T),b.precache(e,function(){b.set.image(e),g.onTopVisible=!1})}))},fixed:function(){b.verbose("Setting up fixed on element pass"),g.once=!1,g.onTopPassed=function(){C.addClass(p.fixed).css({top:g.offset+"px"}),g.transition&&e.fn.transition!==n&&C.transition(g.transition,g.duration)},g.onTopPassedReverse=function(){C.removeClass(p.fixed).css({position:"",top:""})}}},set:{image:function(t){var o=b.cache.screen.bottom<b.cache.element.top;C.attr("src",t),o?(b.verbose("Image outside browser, no show animation"),C.show()):g.transition?e.fn.transition!==n?C.transition(g.transition,g.duration):C.fadeIn(g.duration):C.show()}},is:{visible:function(){return b.cache&&b.cache.element?b.cache.element.width>0:!1}},refresh:function(){b.debug("Refreshing constants (element width/height)"),b.reset(),b.save.position(),b.checkVisibility(),g.onRefresh.call(T)},reset:function(){b.verbose("Reseting all cached values"),e.isPlainObject(b.cache)&&(b.cache.screen={},b.cache.element={})},checkVisibility:function(){b.verbose("Checking visibility of element",b.cache.element),b.is.visible()&&(b.save.calculations(),b.passed(),b.passingReverse(),b.topVisibleReverse(),b.bottomVisibleReverse(),b.topPassedReverse(),b.bottomPassedReverse(),b.passing(),b.topVisible(),b.bottomVisible(),b.topPassed(),b.bottomPassed(),g.onUpdate&&g.onUpdate.call(T,b.get.elementCalculations()))},passed:function(t,o){var s=b.get.elementCalculations();if(t!==n&&o!==n)g.onPassed[t]=o;else{if(t!==n)return b.get.pixelsPassed(t)>s.pixelsPassed;s.passing&&e.each(g.onPassed,function(e,t){s.bottomVisible||s.pixelsPassed>b.get.pixelsPassed(e)?b.execute(t,e):g.once||b.remove.occurred(t)})}},passing:function(e){var t=b.get.elementCalculations(),o=e||g.onPassing,s="passing";return e&&(b.debug("A
|