|
|
/* * # Semantic UI - 1.8.1 * 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,t,o,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,g=b.namespace,f=b.error,v="."+g,h="module-"+g,P=e(t),V=e(this),x=e(b.context),y=(V.offsetParent(),V.selector||"",V.data(h)),R=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},C=this;c={initialize:function(){c.verbose("Initializing visibility",b),c.setup.cache(),c.save.position(),c.should.trackChanges()&&(c.bindEvents(),"image"==b.type&&c.setup.image(),"fixed"==b.type&&c.setup.fixed()),c.checkVisibility(),c.instantiate()},instantiate:function(){c.verbose("Storing instance of module",c),y=c,V.data(h,c)},destroy:function(){c.verbose("Destroying previous module"),V.off(v).removeData(h)},bindEvents:function(){c.verbose("Binding visibility events to scroll and resize"),P.on("resize"+v,c.event.refresh),x.on("scroll"+v,c.event.scroll)},event:{refresh:function(){R(c.refresh)},scroll:function(){c.verbose("Scroll position changed"),b.throttle?(clearTimeout(c.timer),c.timer=setTimeout(c.checkVisibility,b.throttle)):R(c.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?(c.debug("One time query, no need to bind events"),!1):(c.debug("Query is attaching callbacks, watching for changes with scroll"),!0)}},setup:{cache:function(){c.cache={occurred:{},screen:{},element:{}}},image:function(){var e=V.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"),V.visibility({once:!1,continuous:!1,onTopPassed:function(){V.addClass(p.fixed).css({position:"fixed",top:b.offset+"px"}),b.animation&&e.fn.transition!==n&&V.transition(b.transition,b.duration)},onTopPassedReverse:function(){V.removeClass(p.fixed).css({position:"",top:""})}})}},set:{image:function(t){var o=c.cache.screen.bottom<c.cache.element.top;V.attr("src",t),o?(c.verbose("Image outside browser, no show animation"),V.show()):b.transition&&e.fn.transition!==n?V.transition(b.transition,b.duration):V.fadeIn(b.duration)}},refresh:function(){c.debug("Refreshing constants (element width/height)"),c.reset(),c.save.position(),c.checkVisibility(),b.onRefresh.call(C)},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.calculations(),c.passed(),c.passingReverse(),c.topVisibleReverse(),c.bottomVisibleReverse(),c.topPassedReverse(),c.bottomPassedReverse(),c.passing(),c.topVisible(),c.bottomVisible(),c.topPassed(),c.bottomPassed()},passed:function(t,o){var s=c.get.elementCalculations();if(t!==n&&o!==n)b.onPassed[t]=o;else{if(t!==n)return c.get.pixelsPassed(t)>s.pixelsPassed;s.passing&&e.each(b.onPassed,function(e,t){s.bottomVisible||s.pixelsPassed>c.get.pixelsPassed(e)?c.execute(t,e):b.once||c.remove.occurred(t)})}},passing:function(e){var t=c.get.elementCalculations(),o=e||b.onPassing,s="passing";return e&&(c.debug("Adding callback for passing",e),b.onPassing=e),t.passing?c.execute(o,s):b.once||c.remove.occurred(s),e!==n?t.passing:void 0},topVisible:function(e){var t=c.get.elementCalculations(),o=e||b.onTopVisible,s="topVisible";return e&&(c.debug("Adding callback for top visible",e),b.onTopVisible=e),t.topVisible?c.execute(o,s):b.once||c.remove.occurred(s),e===n?t.topVisible:void 0},bottomVisible:function(e){var t=c.get.elementCalculations(),o=e||b.onBottomVisible,s="bottomVisible";return e&&(c.debug("Adding callback for bottom visible",e),b.onBottomVisible=e),t.bottomVisible?c.execute(o,s):b.once|
|