/* Waypoints - 4.0.0 Copyright (c) 2011-2015 Caleb Troughton Licensed under the MIT license. https://github.com/imakewebthings/waypoints/blob/master/licenses.txt */ !function(){function c(d){if(!d){throw new Error("No options passed to Waypoint constructor")}if(!d.element){throw new Error("No element option passed to Waypoint constructor")}if(!d.handler){throw new Error("No handler option passed to Waypoint constructor")}this.key="waypoint-"+a,this.options=c.Adapter.extend({},c.defaults,d),this.element=this.options.element,this.adapter=new c.Adapter(this.element),this.callback=d.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=c.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=c.Context.findOrCreateByElement(this.options.context),c.offsetAliases[this.options.offset]&&(this.options.offset=c.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),b[this.key]=this,a+=1}var a=0,b={};c.prototype.queueTrigger=function(d){this.group.queueTrigger(this,d)},c.prototype.trigger=function(d){this.enabled&&this.callback&&this.callback.apply(this,d)},c.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete b[this.key]},c.prototype.disable=function(){return this.enabled=!1,this},c.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},c.prototype.next=function(){return this.group.next(this)},c.prototype.previous=function(){return this.group.previous(this)},c.invokeAll=function(i){var d=[];for(var g in b){d.push(b[g])}for(var f=0,h=d.length;h>f;f++){d[f][i]()}},c.destroyAll=function(){c.invokeAll("destroy")},c.disableAll=function(){c.invokeAll("disable")},c.enableAll=function(){c.invokeAll("enable")},c.refreshAll=function(){c.Context.refreshAll()},c.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},c.viewportWidth=function(){return document.documentElement.clientWidth},c.adapters=[],c.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},c.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=c}(),function(){function g(e){window.setTimeout(e,1000/60)}function a(e){this.element=e,this.Adapter=c.Adapter,this.adapter=new this.Adapter(e),this.key="waypoint-context-"+b,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},e.waypointContextKey=this.key,d[e.waypointContextKey]=this,b+=1,this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}var b=0,d={},c=window.Waypoint,f=window.onload;a.prototype.add=function(i){var h=i.options.horizontal?"horizontal":"vertical";this.waypoints[h][i.key]=i,this.refresh()},a.prototype.checkEmpty=function(){var i=this.Adapter.isEmptyObject(this.waypoints.horizontal),h=this.Adapter.isEmptyObject(this.waypoints.vertical);i&&h&&(this.adapter.off(".waypoints"),delete d[this.key])},a.prototype.createThrottledResizeHandler=function(){function i(){h.handleResize(),h.didResize=!1}var h=this;this.adapter.on("resize.waypoints",function(){h.didResize||(h.didResize=!0,c.requestAnimationFrame(i))})},a.prototype.createThrottledScrollHandler=function(){function i(){h.handleScroll(),h.didScroll=!1}var h=this;this.adapter.on("scroll.waypoints",function(){(!h.didScroll||c.isTouch)&&(h.didScroll=!0,c.requestAnimationFrame(i))})},a.prototype.handleResize=function(){c.Context.refreshAll()},a.prototype.handleScroll=function(){var C={},m={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var v in m){var y=m[v],x=y.newScroll>y.oldScroll,A=x?y.forward:y.backward;for(var B in this.waypoints[v]){var j=this.waypoints[v][B],w=y.oldScroll=j.triggerPoint,z=w&&q,D=!w&&!q;(z||D)&&(j.queueTrigger(A),C[j.group.id]=j.group)}}for(var k in C){C[k].flushTriggers()}this.oldScroll={x:m.horizontal.newScroll,y:m.vertical.newScroll}},a.prototype.innerHeight=function(){return this.element==this.element.window?c.viewportHeight():this.adapter.innerHeight()},a.prototype.remove=function(e){delete this.waypoints[e.axis][e.key],this.checkEmpty()},a.prototype.innerWidth=function(){return this.element==this.element.window?c.viewportWidth():this.adapter.innerWidth()},a.prototype.destroy=function(){var m=[];for(var h in this.waypoints){for(var j in this.waypoints[h]){m.push(this.waypoints[h][j])}}for(var l=0,k=m.length;k>l;l++){m[l].destroy()}},a.prototype.refresh=function(){var F,n=this.element==this.element.window,z=n?void 0:this.adapter.offset(),B={};this.handleScroll(),F={horizontal:{contextOffset:n?0:z.left,contextScroll:n?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:n?0:z.top,contextScroll:n?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};for(var D in F){var E=F[D];for(var j in this.waypoints[D]){var A,x,C,G,k,m=this.waypoints[D][j],q=m.options.offset,H=m.triggerPoint,I=0,v=null==H;m.element!==m.element.window&&(I=m.adapter.offset()[E.offsetProp]),"function"==typeof q?q=q.apply(m):"string"==typeof q&&(q=parseFloat(q),m.options.offset.indexOf("%")>-1&&(q=Math.ceil(E.contextDimension*q/100))),A=E.contextScroll-E.contextOffset,m.triggerPoint=I+A-q,x=H=E.oldScroll,G=x&&C,k=!x&&!C,!v&&G?(m.queueTrigger(E.backward),B[m.group.id]=m.group):!v&&k?(m.queueTrigger(E.forward),B[m.group.id]=m.group):v&&E.oldScroll>=m.triggerPoint&&(m.queueTrigger(E.forward),B[m.group.id]=m.group)}}return c.requestAnimationFrame(function(){for(var e in B){B[e].flushTriggers()}}),this},a.findOrCreateByElement=function(e){return a.findByElement(e)||new a(e)},a.refreshAll=function(){for(var e in d){d[e].refresh()}},a.findByElement=function(e){return d[e.waypointContextKey]},window.onload=function(){f&&f(),a.refreshAll()},c.requestAnimationFrame=function(h){var j=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||g;j.call(window,h)},c.Context=a}(),function(){function f(h,g){return h.triggerPoint-g.triggerPoint}function a(h,g){return g.triggerPoint-h.triggerPoint}function b(e){this.name=e.name,this.axis=e.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),d[this.axis][this.name]=this}var d={vertical:{},horizontal:{}},c=window.Waypoint;b.prototype.add=function(e){this.waypoints.push(e)},b.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},b.prototype.flushTriggers=function(){for(var g in this.triggerQueues){var j=this.triggerQueues[g],h="up"===g||"left"===g;j.sort(h?a:f);for(var k=0,l=j.length;l>k;k+=1){var e=j[k];(e.options.continuous||k===j.length-1)&&e.trigger([g])}}this.clearTriggerQueues()},b.prototype.next=function(g){this.waypoints.sort(f);var h=c.Adapter.inArray(g,this.waypoints),j=h===this.waypoints.length-1;return j?null:this.waypoints[h+1]},b.prototype.previous=function(g){this.waypoints.sort(f);var h=c.Adapter.inArray(g,this.waypoints);return h?this.waypoints[h-1]:null},b.prototype.queueTrigger=function(h,g){this.triggerQueues[g].push(h)},b.prototype.remove=function(h){var g=c.Adapter.inArray(h,this.waypoints);g>-1&&this.waypoints.splice(g,1)},b.prototype.first=function(){return this.waypoints[0]},b.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},b.findOrCreate=function(e){return d[e.axis][e.name]||new b(e)},c.Group=b}(),function(){function c(d){this.$element=a(d)}var a=window.jQuery,b=window.Waypoint;a.each(["innerHeight","innerWidth","off","offset","on","outerHeight","outerWidth","scrollLeft","scrollTop"],function(d,f){c.prototype[f]=function(){var e=Array.prototype.slice.call(arguments);return this.$element[f].apply(this.$element,e)}}),a.each(["extend","inArray","isEmptyObject"],function(d,e){c[e]=a[e]}),b.adapters.push({name:"jquery",Adapter:c}),b.Adapter=c}(),function(){function b(c){return function(){var d=[],e=arguments[0];return c.isFunction(arguments[0])&&(e=c.extend({},arguments[1]),e.handler=arguments[0]),this.each(function(){var f=c.extend({},e,{element:this});"string"==typeof f.context&&(f.context=c(this).closest(f.context)[0]),d.push(new a(f))}),d}}var a=window.Waypoint;window.jQuery&&(window.jQuery.fn.waypoint=b(window.jQuery)),window.Zepto&&(window.Zepto.fn.waypoint=b(window.Zepto))}();