forked from tumult/hype-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HYPE-596.waypoints.min.js
33 lines (33 loc) · 14.8 KB
/
HYPE-596.waypoints.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function(){var JSCompiler_alias_TRUE=!0,JSCompiler_alias_NULL=null,JSCompiler_alias_FALSE=!1,GLOBAL_window=window,GLOBAL_parseInt=parseInt,$$PROP_push="push",$$PROP_getBoundingClientRect="getBoundingClientRect",$$PROP_innerWidth="innerWidth",$$PROP_requestAnimationFrame="requestAnimationFrame",$$PROP_innerHeight="innerHeight",$$PROP_offset="offset",$$PROP_name="name",$$PROP_window="window",$$PROP_length="length",$$PROP_prototype="prototype",$$PROP_ownerDocument="ownerDocument",$$PROP_group="group",$$PROP_options=
"options",$$PROP_element="element",$$PROP_axis="axis",$$S_="",$$S_$25="%",$$S_$2d="-",$$S_$2e=".",$$S_$5f$5f_default="__default",$$S_default="default",$$S_destroy="destroy",$$S_disable="disable",$$S_down="down",$$S_enable="enable",$$S_enter="enter",$$S_exit="exit",$$S_function="function",$$S_horizontal="horizontal",$$S_left="left",$$S_noframework="noframework",$$S_noop="noop",$$S_object="object",$$S_resize$2ewaypoints="resize.waypoints",$$S_right="right",$$S_scroll$2ewaypoints="scroll.waypoints",
$$S_string="string",$$S_top="top",$$S_up="up",$$S_vertical="vertical",$$S_waypoint$2d="waypoint-",$$S_waypoint$2d_context$2d="waypoint-context-",$$S_waypoints="waypoints";
(function(){function b(c){if(!c)throw Error("No options passed to Waypoint constructor");if(!c[$$PROP_element])throw Error("No element option passed to Waypoint constructor");if(!c.handler)throw Error("No handler option passed to Waypoint constructor");this.key=$$S_waypoint$2d+d;this.options=b.Adapter.extend({},b.defaults,c);this.element=this[$$PROP_options][$$PROP_element];this.adapter=new b.Adapter(this[$$PROP_element]);this.callback=c.handler;this.axis=this[$$PROP_options].horizontal?$$S_horizontal:
$$S_vertical;this.enabled=this[$$PROP_options].enabled;this.triggerPoint=JSCompiler_alias_NULL;this.group=b.Group.findOrCreate({name:this[$$PROP_options][$$PROP_group],axis:this[$$PROP_axis]});this.context=b.Context.findOrCreateByElement(this[$$PROP_options].context);b.offsetAliases[this[$$PROP_options][$$PROP_offset]]&&(this[$$PROP_options].offset=b.offsetAliases[this[$$PROP_options][$$PROP_offset]]);this[$$PROP_group].add(this);this.context.add(this);a[this.key]=this;d+=1}var d=0,a={};b[$$PROP_prototype].queueTrigger=
function(a){this[$$PROP_group].queueTrigger(this,a)};b[$$PROP_prototype].trigger=function(a){this.enabled&&this.callback&&this.callback.apply(this,a)};b[$$PROP_prototype].destroy=function(){this.context.remove(this);this[$$PROP_group].remove(this);delete a[this.key]};b[$$PROP_prototype].disable=function(){this.enabled=JSCompiler_alias_FALSE;return this};b[$$PROP_prototype].enable=function(){this.context.refresh();this.enabled=JSCompiler_alias_TRUE;return this};b[$$PROP_prototype].next=function(){return this[$$PROP_group].next(this)};
b[$$PROP_prototype].previous=function(){return this[$$PROP_group].previous(this)};b.invokeAll=function(c){var b=[],f;for(f in a)b[$$PROP_push](a[f]);f=0;for(var j=b[$$PROP_length];f<j;f++)b[f][c]()};b.destroyAll=function(){b.invokeAll($$S_destroy)};b.disableAll=function(){b.invokeAll($$S_disable)};b.enableAll=function(){b.invokeAll($$S_enable)};b.refreshAll=function(){b.Context.refreshAll()};b.viewportHeight=function(){return GLOBAL_window[$$PROP_innerHeight]||document.documentElement.clientHeight};
b.viewportWidth=function(){return document.documentElement.clientWidth};b.adapters=[];b.defaults={context:GLOBAL_window,continuous:JSCompiler_alias_TRUE,enabled:JSCompiler_alias_TRUE,group:$$S_default,horizontal:JSCompiler_alias_FALSE,offset:0};b.offsetAliases={"bottom-in-view":function(){return this.context[$$PROP_innerHeight]()-this.adapter.outerHeight()},"right-in-view":function(){return this.context[$$PROP_innerWidth]()-this.adapter.outerWidth()}};GLOBAL_window.HYPE_w_596=b})();
(function(){function b(a){GLOBAL_window.setTimeout(a,1E3/60)}function d(j){this.element=j;this.Adapter=e.Adapter;this.adapter=new this.Adapter(j);this.key=$$S_waypoint$2d_context$2d+a;this.didResize=this.didScroll=JSCompiler_alias_FALSE;this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()};this.waypoints={vertical:{},horizontal:{}};j.waypointContextKey=this.key;c[j.waypointContextKey]=this;a+=1;this.createThrottledScrollHandler();this.createThrottledResizeHandler()}var a=0,c={},
e=GLOBAL_window.HYPE_w_596,f=GLOBAL_window.onload;d[$$PROP_prototype].add=function(a){this.waypoints[a[$$PROP_options].horizontal?$$S_horizontal:$$S_vertical][a.key]=a;this.refresh()};d[$$PROP_prototype].checkEmpty=function(){var a=this.Adapter.isEmptyObject(this.waypoints.horizontal),b=this.Adapter.isEmptyObject(this.waypoints.vertical);a&&b&&(this.adapter.off(),delete c[this.key])};d[$$PROP_prototype].createThrottledResizeHandler=function(){function a(){c.handleResize();c.didResize=JSCompiler_alias_FALSE}
var c=this;this.adapter.on($$S_resize$2ewaypoints,function(){c.didResize||(c.didResize=JSCompiler_alias_TRUE,e[$$PROP_requestAnimationFrame](a))})};d[$$PROP_prototype].createThrottledScrollHandler=function(){function a(){c.handleScroll();c.didScroll=JSCompiler_alias_FALSE}var c=this;this.adapter.on($$S_scroll$2ewaypoints,function(){if(!c.didScroll||e.isTouch)c.didScroll=JSCompiler_alias_TRUE,e[$$PROP_requestAnimationFrame](a)})};d[$$PROP_prototype].handleResize=function(){e.Context.refreshAll()};
d[$$PROP_prototype].handleScroll=function(){var a={},c={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:$$S_right,backward:$$S_left},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:$$S_down,backward:$$S_up}},b;for(b in c){var f=c[b],e=f.newScroll>f.oldScroll?f.forward:f.backward,d;for(d in this.waypoints[b]){var h=this.waypoints[b][d],k=f.oldScroll<h.triggerPoint,l=f.newScroll>=h.triggerPoint,n=!k&&!l;if(k&&l||n)h.queueTrigger(e),
a[h[$$PROP_group].id]=h[$$PROP_group]}}for(var r in a)a[r].flushTriggers();this.oldScroll={x:c.horizontal.newScroll,y:c.vertical.newScroll}};d[$$PROP_prototype].innerHeight=function(){return this[$$PROP_element]==this[$$PROP_element][$$PROP_window]?e.viewportHeight():this.adapter[$$PROP_innerHeight]()};d[$$PROP_prototype].remove=function(a){delete this.waypoints[a[$$PROP_axis]][a.key];this.checkEmpty()};d[$$PROP_prototype].innerWidth=function(){return this[$$PROP_element]==this[$$PROP_element][$$PROP_window]?
e.viewportWidth():this.adapter[$$PROP_innerWidth]()};d[$$PROP_prototype].destroy=function(){var a=[],c;for(c in this.waypoints)for(var b in this.waypoints[c])a[$$PROP_push](this.waypoints[c][b]);c=0;for(b=a[$$PROP_length];c<b;c++)a[c].destroy()};d[$$PROP_prototype].refresh=function(){var a=this[$$PROP_element]==this[$$PROP_element][$$PROP_window],c=a?void 0:this.adapter[$$PROP_offset](),b={};this.handleScroll();var a={horizontal:{contextOffset:a?0:c.left,contextScroll:a?0:this.oldScroll.x,contextDimension:this[$$PROP_innerWidth](),
oldScroll:this.oldScroll.x,forward:$$S_right,backward:$$S_left,offsetProp:$$S_left},vertical:{contextOffset:a?0:c.top,contextScroll:a?0:this.oldScroll.y,contextDimension:this[$$PROP_innerHeight](),oldScroll:this.oldScroll.y,forward:$$S_down,backward:$$S_up,offsetProp:$$S_top}},f;for(f in a){var c=a[f],d;for(d in this.waypoints[f]){var g=this.waypoints[f][d],h=g[$$PROP_options][$$PROP_offset],k=g.triggerPoint,l=0,n=k==JSCompiler_alias_NULL;g[$$PROP_element]!==g[$$PROP_element][$$PROP_window]&&(l=g.adapter[$$PROP_offset]()[c.offsetProp]);
typeof h===$$S_function?h=h.apply(g):typeof h===$$S_string&&(h=parseFloat(h),-1<g[$$PROP_options][$$PROP_offset].indexOf($$S_$25)&&(h=Math.ceil(c.contextDimension*h/100)));g.triggerPoint=l+(c.contextScroll-c.contextOffset)-h;k=k<c.oldScroll;l=g.triggerPoint>=c.oldScroll;h=k&&l;k=!k&&!l;!n&&h?(g.queueTrigger(c.backward),b[g[$$PROP_group].id]=g[$$PROP_group]):!n&&k?(g.queueTrigger(c.forward),b[g[$$PROP_group].id]=g[$$PROP_group]):n&&c.oldScroll>=g.triggerPoint&&(g.queueTrigger(c.forward),b[g[$$PROP_group].id]=
g[$$PROP_group])}}e[$$PROP_requestAnimationFrame](function(){for(var a in b)b[a].flushTriggers()});return this};d.findOrCreateByElement=function(a){return d.findByElement(a)||new d(a)};d.refreshAll=function(){for(var a in c)c[a].refresh()};d.findByElement=function(a){return c[a.waypointContextKey]};GLOBAL_window.onload=function(){f&&f();d.refreshAll()};e.requestAnimationFrame=function(a){(GLOBAL_window[$$PROP_requestAnimationFrame]||GLOBAL_window.mozRequestAnimationFrame||GLOBAL_window.webkitRequestAnimationFrame||
b).call(GLOBAL_window,a)};e.Context=d})();
(function(){function b(a,c){return a.triggerPoint-c.triggerPoint}function d(a,c){return c.triggerPoint-a.triggerPoint}function a(a){this.name=a[$$PROP_name];this.axis=a[$$PROP_axis];this.id=this[$$PROP_name]+$$S_$2d+this[$$PROP_axis];this.waypoints=[];this.clearTriggerQueues();c[this[$$PROP_axis]][this[$$PROP_name]]=this}var c={vertical:{},horizontal:{}},e=GLOBAL_window.HYPE_w_596;a[$$PROP_prototype].add=function(a){this.waypoints[$$PROP_push](a)};a[$$PROP_prototype].clearTriggerQueues=function(){this.triggerQueues=
{up:[],down:[],left:[],right:[]}};a[$$PROP_prototype].flushTriggers=function(){for(var a in this.triggerQueues){var c=this.triggerQueues[a];c.sort(a===$$S_up||a===$$S_left?d:b);for(var e=0,q=c[$$PROP_length];e<q;e+=1){var p=c[e];(p[$$PROP_options].continuous||e===c[$$PROP_length]-1)&&p.trigger([a])}}this.clearTriggerQueues()};a[$$PROP_prototype].next=function(a){this.waypoints.sort(b);a=e.Adapter.inArray(a,this.waypoints);return a===this.waypoints[$$PROP_length]-1?JSCompiler_alias_NULL:this.waypoints[a+
1]};a[$$PROP_prototype].previous=function(a){this.waypoints.sort(b);return(a=e.Adapter.inArray(a,this.waypoints))?this.waypoints[a-1]:JSCompiler_alias_NULL};a[$$PROP_prototype].queueTrigger=function(a,c){this.triggerQueues[c][$$PROP_push](a)};a[$$PROP_prototype].remove=function(a){a=e.Adapter.inArray(a,this.waypoints);-1<a&&this.waypoints.splice(a,1)};a[$$PROP_prototype].first=function(){return this.waypoints[0]};a[$$PROP_prototype].last=function(){return this.waypoints[this.waypoints[$$PROP_length]-
1]};a.findOrCreate=function(b){return c[b[$$PROP_axis]][b[$$PROP_name]]||new a(b)};e.Group=a})();
(function(){function b(a){this.element=a;this.handlers={}}var d=GLOBAL_window.HYPE_w_596;b[$$PROP_prototype].innerHeight=function(){var a=0;this[$$PROP_element]===this[$$PROP_element][$$PROP_window]?a=this[$$PROP_element][$$PROP_innerHeight]:(a=this[$$PROP_element].clientHeight,this[$$PROP_element][$$PROP_getBoundingClientRect]&&(a=this[$$PROP_element][$$PROP_getBoundingClientRect](),a=a.bottom-a.top));return a};b[$$PROP_prototype].innerWidth=function(){var a=0;this[$$PROP_element]===this[$$PROP_element][$$PROP_window]?
a=this[$$PROP_element][$$PROP_innerWidth]:(a=this[$$PROP_element].clientWidth,this[$$PROP_element][$$PROP_getBoundingClientRect]&&(a=this[$$PROP_element][$$PROP_getBoundingClientRect](),a=a.right-a.left));return a};b[$$PROP_prototype].off=function(){function a(a,c){for(var b=0,d=c[$$PROP_length]-1;b<d;b++)a.removeEventListener(c[b])}var c=[$$S_,$$S_waypoints],b=c[0],c=c[1],d=this[$$PROP_element];if(c&&this.handlers[c]&&b)a(d,this.handlers[c][b]),this.handlers[c][b]=[];else if(b)for(var j in this.handlers)a(d,
this.handlers[j][b]||[]),this.handlers[j][b]=[];else if(c&&this.handlers[c]){for(var m in this.handlers[c])a(d,this.handlers[c][m]);this.handlers[c]={}}};b[$$PROP_prototype].offset=function(){if(!this[$$PROP_element][$$PROP_ownerDocument])return JSCompiler_alias_NULL;var a=this[$$PROP_element][$$PROP_ownerDocument].documentElement,c=this[$$PROP_element][$$PROP_ownerDocument]===this[$$PROP_element][$$PROP_ownerDocument][$$PROP_window]?this[$$PROP_element][$$PROP_ownerDocument]:this[$$PROP_element][$$PROP_ownerDocument].defaultView,
b={top:0,left:0};this[$$PROP_element][$$PROP_getBoundingClientRect]&&(b=this[$$PROP_element][$$PROP_getBoundingClientRect]());return{top:b.top+c.pageYOffset-a.clientTop,left:b.left+c.pageXOffset-a.clientLeft}};b[$$PROP_prototype].on=function(a,c){var b=a.split($$S_$2e),d=b[0],b=b[1]||$$S_$5f$5f_default,b=this.handlers[b]=this.handlers[b]||{};(b[d]=b[d]||[])[$$PROP_push](c);this[$$PROP_element].addEventListener(d,c)};b[$$PROP_prototype].outerHeight=function(a){var c=this[$$PROP_innerHeight]();a&&this[$$PROP_element]!==
this[$$PROP_element][$$PROP_window]&&(a=GLOBAL_window.getComputedStyle(this[$$PROP_element]),c+=GLOBAL_parseInt(a.marginTop,10),c+=GLOBAL_parseInt(a.marginBottom,10));return c};b[$$PROP_prototype].outerWidth=function(a){var c=this[$$PROP_innerWidth]();a&&this[$$PROP_element]!==this[$$PROP_element][$$PROP_window]&&(a=GLOBAL_window.getComputedStyle(this[$$PROP_element]),c+=GLOBAL_parseInt(a.marginLeft,10),c+=GLOBAL_parseInt(a.marginRight,10));return c};b[$$PROP_prototype].scrollLeft=function(){var a=
this[$$PROP_element]===this[$$PROP_element][$$PROP_window]?this[$$PROP_element]:this[$$PROP_element].defaultView;return a?a.pageXOffset:this[$$PROP_element].scrollLeft};b[$$PROP_prototype].scrollTop=function(){var a=this[$$PROP_element]===this[$$PROP_element][$$PROP_window]?this[$$PROP_element]:this[$$PROP_element].defaultView;return a?a.pageYOffset:this[$$PROP_element].scrollTop};b.extend=function(){for(var a=Array[$$PROP_prototype].slice.call(arguments),c=1,b=a[$$PROP_length];c<b;c++){var d=a[0],
j=a[c];if(typeof d===$$S_object&&typeof j===$$S_object){var m=void 0;for(m in j)j.hasOwnProperty(m)&&(d[m]=j[m])}}return a[0]};b.inArray=function(a,c){return c==JSCompiler_alias_NULL?-1:c.indexOf(a,void 0)};b.isEmptyObject=function(a){for(var c in a)return JSCompiler_alias_FALSE;return JSCompiler_alias_TRUE};d.adapters[$$PROP_push]({name:$$S_noframework,Adapter:b});d.Adapter=b})();
(function(){function b(){}function d(c){this.options=a.Adapter.extend({},d.defaults,c);this.axis=this[$$PROP_options].horizontal?$$S_horizontal:$$S_vertical;this.waypoints=[];this.createWaypoints()}var a=GLOBAL_window.HYPE_w_596;d[$$PROP_prototype].createWaypoints=function(){for(var a=this,b={vertical:[{down:$$S_enter,up:$$S_noop,offset:function(){return this.context[$$PROP_innerHeight]()-a[$$PROP_options].elementOffset}},{down:$$S_noop,up:$$S_exit,offset:function(){return this.context[$$PROP_innerHeight]()}},
{down:$$S_exit,up:$$S_noop,offset:function(){return-this.adapter.outerHeight()}},{down:$$S_noop,up:$$S_enter,offset:function(){return-this.adapter.outerHeight()+a[$$PROP_options].elementOffset}}]},d=0,j=b[this[$$PROP_axis]][$$PROP_length];d<j;d++)this.createWaypoint(b[this[$$PROP_axis]][d])};d[$$PROP_prototype].createWaypoint=function(c){var b=this;this.waypoints[$$PROP_push](new a({element:this[$$PROP_options][$$PROP_element],handler:function(a){return function(c){b[$$PROP_options][a[c]].call(this,
c);b[$$PROP_options].triggerOnce&&this.destroy()}}(c),offset:c[$$PROP_offset],horizontal:this[$$PROP_options].horizontal}))};d[$$PROP_prototype].destroy=function(){for(var a=0,b=this.waypoints[$$PROP_length];a<b;a++)this.waypoints[a].destroy();this.waypoints=[]};d.defaults={enter:b,entered:b,exit:b,exited:b,noop:b};a.hypeS=d})();
(function(){var b=[];GLOBAL_window.HYPE_wdtl_596!=JSCompiler_alias_NULL&&(b=GLOBAL_window.HYPE_wdtl_596.slice(0));GLOBAL_window.HYPE_wdtl_596=JSCompiler_alias_NULL;for(var d=0;d<b[$$PROP_length];d++)b[d]()})();})();