12 |
- /* ScrollMagic v2.0.6 | (c) 2018 Jan Paepke (@janpaepke) | license & info: http://scrollmagic.io */
- !function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.ScrollMagic=b()}(this,function(){var a=function(){};a.version="2.0.6",window.addEventListener("mousewheel",function(){});var f="data-scrollmagic-pin-spacer";a.Controller=function(Q){var O,R,e="ScrollMagic.Controller",I="FORWARD",k="REVERSE",B="PAUSED",W=c.defaults,q=this,H=b.extend({},W,Q),G=[],P=!1,X=0,K=B,Y=!0,aa=0,U=!0,j=function(){for(var g in H){W.hasOwnProperty(g)||delete H[g]}if(H.container=b.get.elements(H.container)[0],!H.container){throw e+" init failed."}Y=H.container===window||H.container===document.body||!document.body.contains(H.container),Y&&(H.container=window),aa=ab(),H.container.addEventListener("resize",V),H.container.addEventListener("scroll",V);var h=parseInt(H.refreshInterval,10);H.refreshInterval=b.type.Number(h)?h:W.refreshInterval,t()},t=function(){H.refreshInterval>0&&(R=window.setTimeout(i,H.refreshInterval))},Z=function(){return H.vertical?b.get.scrollTop(H.container):b.get.scrollLeft(H.container)},ab=function(){return H.vertical?b.get.height(H.container):b.get.width(H.container)},n=this._setScrollPos=function(g){H.vertical?Y?window.scrollTo(b.get.scrollLeft(),g):H.container.scrollTop=g:Y?window.scrollTo(g,b.get.scrollTop()):H.container.scrollLeft=g},D=function(){if(U&&P){var g=b.type.Array(P)?P:G.slice(0);P=!1;var l=X;X=q.scrollPos();var h=X-l;0!==h&&(K=h>0?I:k),K===k&&g.reverse(),g.forEach(function(m){m.update(!0)})}},J=function(){O=b.rAF(D)},V=function(g){"resize"==g.type&&(aa=ab(),K=B),P!==!0&&(P=!0,J())},i=function(){if(!Y&&aa!=ab()){var g;try{g=new Event("resize",{bubbles:!1,cancelable:!1})}catch(h){g=document.createEvent("Event"),g.initEvent("resize",!1,!1)}H.container.dispatchEvent(g)}G.forEach(function(l){l.refresh()}),t()};this._options=H;var M=function(g){if(g.length<=1){return g}var h=g.slice(0);return h.sort(function(l,m){return l.scrollOffset()>m.scrollOffset()?1:-1}),h};return this.addScene=function(h){if(b.type.Array(h)){h.forEach(function(l){q.addScene(l)})}else{if(h instanceof a.Scene){if(h.controller()!==q){h.addTo(q)}else{if(G.indexOf(h)<0){G.push(h),G=M(G),h.on("shift.controller_sort",function(){G=M(G)});for(var g in H.globalSceneOptions){h[g]&&h[g].call(h,H.globalSceneOptions[g])}}}}}return q},this.removeScene=function(g){if(b.type.Array(g)){g.forEach(function(l){q.removeScene(l)})}else{var h=G.indexOf(g);h>-1&&(g.off("shift.controller_sort"),G.splice(h,1),g.remove())}return q},this.updateScene=function(h,g){return b.type.Array(h)?h.forEach(function(l){q.updateScene(l,g)}):g?h.update(!0):P!==!0&&h instanceof a.Scene&&(P=P||[],-1==P.indexOf(h)&&P.push(h),P=M(P),J()),q},this.update=function(g){return V({type:"resize"}),g&&D(),q},this.scrollTo=function(m,u){if(b.type.Number(m)){n.call(H.container,m,u)}else{if(m instanceof a.Scene){m.controller()===q&&q.scrollTo(m.scrollOffset(),u)}else{if(b.type.Function(m)){n=m}else{var p=b.get.elements(m)[0];if(p){for(;p.parentNode.hasAttribute(f);){p=p.parentNode}var v=H.vertical?"top":"left",g=b.get.offset(H.container),h=b.get.offset(p);Y||(g[v]-=q.scrollPos()),q.scrollTo(h[v]-g[v],u)}}}}return q},this.scrollPos=function(g){return arguments.length?(b.type.Function(g)&&(Z=g),q):Z.call(q)},this.info=function(g){var h={size:aa,vertical:H.vertical,scrollPos:X,scrollDirection:K,container:H.container,isDocument:Y};return arguments.length?void 0!==h[g]?h[g]:void 0:h},this.loglevel=function(){return q},this.enabled=function(g){return arguments.length?(U!=g&&(U=!!g,q.updateScene(G,!0)),q):U},this.destroy=function(g){window.clearTimeout(R);for(var h=G.length;h--;){G[h].destroy(g)}return H.container.removeEventListener("resize",V),H.container.removeEventListener("scroll",V),b.cAF(O),null},j(),q};var c={defaults:{container:window,vertical:!0,globalSceneOptions:{},loglevel:2,refreshInterval:100}};a.Controller.addOption=function(g,h){c.defaults[g]=h},a.Controller.extend=function(g){var e=this;a.Controller=function(){return e.apply(this,arguments),this.$super=b.extend({},this),g.apply(this,arguments)||this},b.extend(a.Controller,e),a.Controller.prototype=e.prototype,a.Controller.prototype.constructor=a.Controller},a.Scene=function(X){var Z,ae,i="BEFORE",U="DURING",r="AFTER",I=d.defaults,ah=this,B=b.extend({},I,X),M=i,K=0,ab={start:0,end:0},ai=0,W=!0,aj=function(){for(var g in B){I.hasOwnProperty(g)||delete B[g]}for(var h in I){V(h)}t()},al={};this.on=function(g,h){return b.type.Function(h)&&(g=g.trim().split(" "),g.forEach(function(k){var m=k.split("."),o=m[0],l=m[1];"*"!=o&&(al[o]||(al[o]=[]),al[o].push({namespace:l||"",callback:h}))})),ah},this.off=function(g,h){return g?(g=g.trim().split(" "),g.forEach(function(k){var m=k.split("."),s=m[0],l=m[1]||"",p="*"===s?Object.keys(al):[s];p.forEach(function(u){for(var v=al[u]||[],x=v.length;x--;){var w=v[x];!w||l!==w.namespace&&"*"!==l||h&&h!=w.callback||v.splice(x,1)}v.length||delete al[u]})}),ah):ah},this.trigger=function(p,h){if(p){var l=p.trim().split("."),g=l[0],k=l[1],m=al[g];m&&m.forEach(function(n){k&&k!==n.namespace||n.callback.call(ah,new a.Event(g,n.namespace,ah,h))})}return ah},ah.on("change.internal",function(g){"loglevel"!==g.what&&"tweenChanges"!==g.what&&("triggerElement"===g.what?H():"reverse"===g.what&&ah.update())}).on("shift.internal",function(){af(),ah.update()}),this.addTo=function(g){return g instanceof a.Controller&&ae!=g&&(ae&&ae.removeScene(ah),ae=g,t(),q(!0),H(!0),af(),ae.info("container").addEventListener("resize",ak),g.addScene(ah),ah.trigger("add",{controller:ae}),ah.update()),ah},this.enabled=function(g){return arguments.length?(W!=g&&(W=!!g,ah.update(!0)),ah):W},this.remove=function(){if(ae){ae.info("container").removeEventListener("resize",ak);var g=ae;ae=void 0,g.removeScene(ah),ah.trigger("remove")}return ah},this.destroy=function(g){return ah.trigger("destroy",{reset:g}),ah.remove(),ah.off("*.*"),null},this.update=function(g){if(ae){if(g){if(ae.enabled()&&W){var k,h=ae.info("scrollPos");k=B.duration>0?(h-ab.start)/(ab.end-ab.start):h>=ab.start?1:0,ah.trigger("update",{startPos:ab.start,endPos:ab.end,scrollPos:h}),ah.progress(k)}else{ag&&M===U&&Y(!0)}}else{ae.updateScene(ah,!1)}}return ah},this.refresh=function(){return q(),H(),ah},this.progress=function(g){if(arguments.length){var v=!1,l=M,u=ae?ae.info("scrollDirection"):"PAUSED",k=B.reverse||g>=K;if(0===B.duration?(v=K!=g,K=1>g&&k?0:1,M=0===K?i:U):0>g&&M!==i&&k?(K=0,M=i,v=!0):g>=0&&1>g&&k?(K=g,M=U,v=!0):g>=1&&M!==r?(K=1,M=r,v=!0):M!==U||k||Y(),v){var m={progress:K,state:M,scrollDirection:u},h=M!=l,s=function(n){ah.trigger(n,m)};h&&l!==U&&(s("enter"),s(l===i?"start":"end")),s("progress"),h&&M!==U&&(s(M===i?"start":"end"),s("leave"))}return ah}return K};var af=function(){ab={start:ai+B.offset},ae&&B.triggerElement&&(ab.start-=ae.info("size")*B.triggerHook),ab.end=ab.start+B.duration},q=function(g){if(Z){var h="duration";J(h,Z.call(ah))&&!g&&(ah.trigger("change",{what:h,newval:B[h]}),ah.trigger("shift",{reason:h}))}},H=function(k){var s=0,v=B.triggerElement;if(ae&&(v||ai>0)){if(v){if(v.parentNode){for(var u=ae.info(),g=b.get.offset(u.container),p=u.vertical?"top":"left";v.parentNode.hasAttribute(f);){v=v.parentNode}var h=b.get.offset(v);u.isDocument||(g[p]-=ae.scrollPos()),s=h[p]-g[p]}else{ah.triggerElement(void 0)}}var m=s!=ai;ai=s,m&&!k&&ah.trigger("shift",{reason:"triggerElementPosition"})}},ak=function(){B.triggerHook>0&&ah.trigger("shift",{reason:"containerResize"})},am=b.extend(d.validate,{duration:function(g){if(b.type.String(g)&&g.match(/^(\.|\d)*\d+%$/)){var k=parseFloat(g)/100;g=function(){return ae?ae.info("size")*k:0}}if(b.type.Function(g)){Z=g;try{g=parseFloat(Z())}catch(h){g=-1}}if(g=parseFloat(g),!b.type.Number(g)||0>g){throw Z?(Z=void 0,0):0}return g}}),t=function(g){g=arguments.length?[g]:Object.keys(am),g.forEach(function(h){var l;if(am[h]){try{l=am[h](B[h])}catch(k){l=I[h]}finally{B[h]=l}}})},J=function(g,l){var h=!1,k=B[g];return B[g]!=l&&(B[g]=l,t(g),h=k!=B[g]),h},V=function(g){ah[g]||(ah[g]=function(h){return arguments.length?("duration"===g&&(Z=void 0),J(g,h)&&(ah.trigger("change",{what:g,newval:B[g]}),d.shifts.indexOf(g)>-1&&ah.trigger("shift",{reason:g})),ah):B[g]})};this.controller=function(){return ae},this.state=function(){return M},this.scrollOffset=function(){return ab.start},this.triggerPosition=function(){var g=B.offset;return ae&&(g+=B.triggerElement?ai:ae.info("size")*ah.triggerHook()),g};var ag,j;ah.on("shift.internal",function(g){var h="duration"===g.reason;(M===r&&h||M===U&&0===B.duration)&&Y(),h&&aa()}).on("progress.internal",function(){Y()}).on("add.internal",function(){aa()}).on("destroy.internal",function(g){ah.removePin(g.reset)});var Y=function(g){if(ag&&ae){var p=ae.info(),k=j.spacer.firstChild;if(g||M!==U){var m={position:j.inFlow?"relative":"absolute",top:0,left:0},l=b.css(k,"position")!=m.position;j.pushFollowers?B.duration>0&&(M===r&&0===parseFloat(b.css(j.spacer,"padding-top"))?l=!0:M===i&&0===parseFloat(b.css(j.spacer,"padding-bottom"))&&(l=!0)):m[p.vertical?"top":"left"]=B.duration*K,b.css(k,m),l&&aa()}else{"fixed"!=b.css(k,"position")&&(b.css(k,{position:"fixed"}),aa());var h=b.get.offset(j.spacer,!0),s=B.reverse||0===B.duration?p.scrollPos-ab.start:Math.round(K*B.duration*10)/10;h[p.vertical?"top":"left"]+=s,b.css(j.spacer.firstChild,{top:h.top,left:h.left})}}},aa=function(){if(ag&&ae&&j.inFlow){var g=M===U,m=ae.info("vertical"),h=j.spacer.firstChild,l=b.isMarginCollapseType(b.css(j.spacer,"display")),k={};j.relSize.width||j.relSize.autoFullWidth?g?b.css(ag,{width:b.get.width(j.spacer)}):b.css(ag,{width:"100%"}):(k["min-width"]=b.get.width(m?ag:h,!0,!0),k.width=g?k["min-width"]:"auto"),j.relSize.height?g?b.css(ag,{height:b.get.height(j.spacer)-(j.pushFollowers?B.duration:0)}):b.css(ag,{height:"100%"}):(k["min-height"]=b.get.height(m?h:ag,!0,!l),k.height=g?k["min-height"]:"auto"),j.pushFollowers&&(k["padding"+(m?"Top":"Left")]=B.duration*K,k["padding"+(m?"Bottom":"Right")]=B.duration*(1-K)),b.css(j.spacer,k)}},e=function(){ae&&ag&&M===U&&!ae.info("isDocument")&&Y()},ac=function(){ae&&ag&&M===U&&((j.relSize.width||j.relSize.autoFullWidth)&&b.get.width(window)!=b.get.width(j.spacer.parentNode)||j.relSize.height&&b.get.height(window)!=b.get.height(j.spacer.parentNode))&&aa()},G=function(g){ae&&ag&&M===U&&!ae.info("isDocument")&&(g.preventDefault(),ae._setScrollPos(ae.info("scrollPos")-((g.wheelDelta||g[ae.info("vertical")?"wheelDeltaY":"wheelDeltaX"])/3||30*-g.detail)))};this.setPin=function(u,z){var C={pushFollowers:!0,spacerClass:"scrollmagic-pin-spacer"};if(z=b.extend({},C,z),u=b.get.elements(u)[0],!u){return ah}if("fixed"===b.css(u,"position")){return ah}if(ag){if(ag===u){return ah}ah.removePin()}ag=u;var A=ag.parentNode.style.display,D=["top","left","bottom","right","margin","marginLeft","marginRight","marginTop","marginBottom"];ag.parentNode.style.display="none";var k="absolute"!=b.css(ag,"position"),y=b.css(ag,D.concat(["display"])),m=b.css(ag,["width","height"]);ag.parentNode.style.display=A,!k&&z.pushFollowers&&(z.pushFollowers=!1);var v=ag.parentNode.insertBefore(document.createElement("div"),ag),p=b.extend(y,{position:k?"relative":"absolute",boxSizing:"content-box",mozBoxSizing:"content-box",webkitBoxSizing:"content-box"});if(k||b.extend(p,b.css(ag,["width","height"])),b.css(v,p),v.setAttribute(f,""),b.addClass(v,z.spacerClass),j={spacer:v,relSize:{width:"%"===m.width.slice(-1),height:"%"===m.height.slice(-1),autoFullWidth:"auto"===m.width&&k&&b.isMarginCollapseType(y.display)},pushFollowers:z.pushFollowers,inFlow:k},!ag.___origStyle){ag.___origStyle={};var x=ag.style,w=D.concat(["width","height","position","boxSizing","mozBoxSizing","webkitBoxSizing"]);w.forEach(function(g){ag.___origStyle[g]=x[g]||""})}return j.relSize.width&&b.css(v,{width:m.width}),j.relSize.height&&b.css(v,{height:m.height}),v.appendChild(ag),b.css(ag,{position:k?"relative":"absolute",margin:"auto",top:"auto",left:"auto",bottom:"auto",right:"auto"}),(j.relSize.width||j.relSize.autoFullWidth)&&b.css(ag,{boxSizing:"border-box",mozBoxSizing:"border-box",webkitBoxSizing:"border-box"}),window.addEventListener("scroll",e),window.addEventListener("resize",e),window.addEventListener("resize",ac),ag.addEventListener("mousewheel",G),ag.addEventListener("DOMMouseScroll",G),Y(),ah},this.removePin=function(h){if(ag){if(M===U&&Y(!0),h||!ae){var k=j.spacer.firstChild;if(k.hasAttribute(f)){var m=j.spacer.style,l=["margin","marginLeft","marginRight","marginTop","marginBottom"],g={};l.forEach(function(n){g[n]=m[n]||""}),b.css(k,g)}j.spacer.parentNode.insertBefore(k,j.spacer),j.spacer.parentNode.removeChild(j.spacer),ag.parentNode.hasAttribute(f)||(b.css(ag,ag.___origStyle),delete ag.___origStyle)}window.removeEventListener("scroll",e),window.removeEventListener("resize",e),window.removeEventListener("resize",ac),ag.removeEventListener("mousewheel",G),ag.removeEventListener("DOMMouseScroll",G),ag=void 0}return ah};var ad,Q=[];return ah.on("destroy.internal",function(g){ah.removeClassToggle(g.reset)}),this.setClassToggle=function(g,k){var h=b.get.elements(g);return 0!==h.length&&b.type.String(k)?(Q.length>0&&ah.removeClassToggle(),ad=k,Q=h,ah.on("enter.internal_class leave.internal_class",function(l){var m="enter"===l.type?b.addClass:b.removeClass;Q.forEach(function(n){m(n,ad)})}),ah):ah},this.removeClassToggle=function(g){return g&&Q.forEach(function(h){b.removeClass(h,ad)}),ah.off("start.internal_class end.internal_class"),ad=void 0,Q=[],ah},aj(),ah};var d={defaults:{duration:0,offset:0,triggerElement:void 0,triggerHook:0.5,reverse:!0,loglevel:2},validate:{offset:function(g){if(g=parseFloat(g),!b.type.Number(g)){throw 0}return g},triggerElement:function(g){if(g=g||void 0){var h=b.get.elements(g)[0];if(!h||!h.parentNode){throw 0}g=h}return g},triggerHook:function(g){var h={onCenter:0.5,onEnter:1,onLeave:0};if(b.type.Number(g)){g=Math.max(0,Math.min(parseFloat(g),1))}else{if(!(g in h)){throw 0}g=h[g]}return g},reverse:function(g){return !!g}},shifts:["duration","offset","triggerHook"]};a.Scene.addOption=function(g,k,j,h){g in d.defaults||(d.defaults[g]=k,d.validate[g]=j,h&&d.shifts.push(g))},a.Scene.extend=function(g){var e=this;a.Scene=function(){return e.apply(this,arguments),this.$super=b.extend({},this),g.apply(this,arguments)||this},b.extend(a.Scene,e),a.Scene.prototype=e.prototype,a.Scene.prototype.constructor=a.Scene},a.Event=function(g,l,j,k){k=k||{};for(var h in k){this[h]=k[h]}return this.type=g,this.target=this.currentTarget=j,this.namespace=l||"",this.timeStamp=this.timestamp=Date.now(),this};var b=a._util=function(k){var z,v={},x=function(i){return parseFloat(i)||0},p=function(e){return e.currentStyle?e.currentStyle:k.getComputedStyle(e)},w=function(C,r,u,B){if(r=r===document?k:r,r===k){B=!1}else{if(!A.DomElement(r)){return 0}}C=C.charAt(0).toUpperCase()+C.substr(1).toLowerCase();var e=(u?r["offset"+C]||r["outer"+C]:r["client"+C]||r["inner"+C])||0;if(u&&B){var i=p(r);e+="Height"===C?x(i.marginTop)+x(i.marginBottom):x(i.marginLeft)+x(i.marginRight)}return e},y=function(i){return i.replace(/^[^a-z]+([a-z])/g,"$1").replace(/-([a-z])/g,function(l){return l[1].toUpperCase()})};v.extend=function(i){for(i=i||{},z=1;z<arguments.length;z++){if(arguments[z]){for(var l in arguments[z]){arguments[z].hasOwnProperty(l)&&(i[l]=arguments[z][l])}}}return i},v.isMarginCollapseType=function(i){return["block","flex","list-item","table","-webkit-box"].indexOf(i)>-1};var g=0,q=["ms","moz","webkit","o"],h=k.requestAnimationFrame,m=k.cancelAnimationFrame;for(z=0;!h&&z<q.length;++z){h=k[q[z]+"RequestAnimationFrame"],m=k[q[z]+"CancelAnimationFrame"]||k[q[z]+"CancelRequestAnimationFrame"]}h||(h=function(s){var l=(new Date).getTime(),o=Math.max(0,16-(l-g)),e=k.setTimeout(function(){s(l+o)},o);return g=l+o,e}),m||(m=function(e){k.clearTimeout(e)}),v.rAF=h.bind(k),v.cAF=m.bind(k);var A=v.type=function(i){return Object.prototype.toString.call(i).replace(/^\[object (.+)\]$/,"$1").toLowerCase()};A.String=function(i){return"string"===A(i)},A.Function=function(i){return"function"===A(i)},A.Array=function(i){return Array.isArray(i)},A.Number=function(i){return !A.Array(i)&&i-parseFloat(i)+1>=0},A.DomElement=function(i){return"object"==typeof HTMLElement?i instanceof HTMLElement:i&&"object"==typeof i&&null!==i&&1===i.nodeType&&"string"==typeof i.nodeName};var j=v.get={};return j.elements=function(D){var l=[];if(A.String(D)){try{D=document.querySelectorAll(D)}catch(B){return l}}if("nodelist"===A(D)||A.Array(D)){for(var e=0,u=l.length=D.length;u>e;e++){var C=D[e];l[e]=A.DomElement(C)?C:j.elements(C)}}else{(A.DomElement(D)||D===document||D===k)&&(l=[D])}return l},j.scrollTop=function(e){return e&&"number"==typeof e.scrollTop?e.scrollTop:k.pageYOffset||0},j.scrollLeft=function(e){return e&&"number"==typeof e.scrollLeft?e.scrollLeft:k.pageXOffset||0},j.width=function(i,o,l){return w("width",i,o,l)},j.height=function(i,o,l){return w("height",i,o,l)},j.offset=function(i,s){var l={top:0,left:0};if(i&&i.getBoundingClientRect){var o=i.getBoundingClientRect();l.top=o.top,l.left=o.left,s||(l.top+=j.scrollTop(),l.left+=j.scrollLeft())}return l},v.addClass=function(i,l){l&&(i.classList?i.classList.add(l):i.className+=" "+l)},v.removeClass=function(i,l){l&&(i.classList?i.classList.remove(l):i.className=i.className.replace(RegExp("(^|\\b)"+l.split(" ").join("|")+"(\\b|$)","gi")," "))},v.css=function(l,C){if(A.String(C)){return p(l)[y(C)]}if(A.Array(C)){var s={},B=p(l);return C.forEach(function(n){s[n]=B[y(n)]}),s}for(var u in C){var i=C[u];i==parseFloat(i)&&(i+="px"),l.style[y(u)]=i}},v}(window||{});return a});
|