Files

12 lines
23 KiB
JavaScript
Raw Permalink Normal View History

/*!
* ScrollMagic v2.0.7 (2019-05-07)
* The javascript library for magical scroll interactions.
* (c) 2019 Jan Paepke (@janpaepke)
* Project Website: http://scrollmagic.io
*
* @version 2.0.7
* @license Dual licensed under MIT license and GPL.
* @author Jan Paepke - e-mail@janpaepke.de
*
* @file ScrollMagic main library.
*/(function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.ScrollMagic=t()})(this,function(){"use strict";var e=function(){n.log(2,"(COMPATIBILITY NOTICE) -> As of ScrollMagic 2.0.0 you need to use 'new ScrollMagic.Controller()' to create a new controller instance. Use 'new ScrollMagic.Scene()' to instance a scene.")};e.version="2.0.7",window.addEventListener("mousewheel",function(){});e.Controller=function(o){var r,l,i=t.defaults,a=this,s=n.extend({},i,o),c=[],d=!1,g=0,p="PAUSED",u=!0,m=0,h=!0,f=function(){0<s.refreshInterval&&(l=window.setTimeout(b,s.refreshInterval))},v=function(){return s.vertical?n.get.scrollTop(s.container):n.get.scrollLeft(s.container)},S=function(){return s.vertical?n.get.height(s.container):n.get.width(s.container)},y=this._setScrollPos=function(e){s.vertical?u?window.scrollTo(n.get.scrollLeft(),e):s.container.scrollTop=e:u?window.scrollTo(e,n.get.scrollTop()):s.container.scrollLeft=e},E=function(){if(h&&d){var e=n.type.Array(d)?d:c.slice(0);d=!1;var t=g;g=a.scrollPos();var o=g-t;0!=o&&(p=0<o?"FORWARD":"REVERSE"),"REVERSE"===p&&e.reverse(),e.forEach(function(t,o){N(3,"updating Scene "+(o+1)+"/"+e.length+" ("+c.length+" total)"),t.update(!0)}),0===e.length&&3<=s.loglevel&&N(3,"updating 0 Scenes (nothing added to controller)")}},R=function(){r=n.rAF(E)},w=function(t){N(3,"event fired causing an update:",t.type),"resize"==t.type&&(m=S(),p="PAUSED"),!0!==d&&(d=!0,R())},b=function(){if(!u&&m!=S()){var t;try{t=new Event("resize",{bubbles:!1,cancelable:!1})}catch(o){t=document.createEvent("Event"),t.initEvent("resize",!1,!1)}s.container.dispatchEvent(t)}c.forEach(function(e,t){e.refresh()}),f()},N=this._log=function(e,t){s.loglevel>=e&&(Array.prototype.splice.call(arguments,1,0,"(ScrollMagic.Controller) ->"),n.log.apply(window,arguments))};this._options=s;var T=function(e){if(1>=e.length)return e;var t=e.slice(0);return t.sort(function(e,t){return e.scrollOffset()>t.scrollOffset()?1:-1}),t};return this.addScene=function(t){if(n.type.Array(t))t.forEach(function(e,t){a.addScene(e)});else if(!(t instanceof e.Scene))N(1,"ERROR: invalid argument supplied for '.addScene()'");else if(t.controller()!==a)t.addTo(a);else if(0>c.indexOf(t)){for(var o in c.push(t),c=T(c),t.on("shift.controller_sort",function(){c=T(c)}),s.globalSceneOptions)t[o]&&t[o].call(t,s.globalSceneOptions[o]);N(3,"adding Scene (now "+c.length+" total)")}return a},this.removeScene=function(e){if(n.type.Array(e))e.forEach(function(e,t){a.removeScene(e)});else{var t=c.indexOf(e);-1<t&&(e.off("shift.controller_sort"),c.splice(t,1),N(3,"removing Scene (now "+c.length+" left)"),e.remove())}return a},this.updateScene=function(t,o){return n.type.Array(t)?t.forEach(function(e,t){a.updateScene(e,o)}):o?t.update(!0):!0!==d&&t instanceof e.Scene&&(d=d||[],-1==d.indexOf(t)&&d.push(t),d=T(d),R()),a},this.update=function(e){return w({type:"resize"}),e&&E(),a},this.scrollTo=function(t,o){if(n.type.Number(t))y.call(s.container,t,o);else if(t instanceof e.Scene)t.controller()===a?a.scrollTo(t.scrollOffset(),o):N(2,"scrollTo(): The supplied scene does not belong to this controller. Scroll cancelled.",t);else if(n.type.Function(t))y=t;else{var r=n.get.elements(t)[0];if(r){for(;r.parentNode.hasAttribute("data-scrollmagic-pin-spacer");)r=r.parentNode;var l=s.vertical?"top":"left",i=n.get.offset(s.container),c=n.get.offset(r);u||(i[l]-=a.scrollPos()),a.scrollTo(c[l]-i[l],o)}else N(2,"scrollTo(): The supplied argument is invalid. Scroll cancelled.",t)}return a},this.scrollPos=function(e){return arguments.length?(n.type.Function(e)?v=e:N(2,"Provided value for method 'scrollPos' is not a function. To change the current scroll position use 'scrollTo()'."),a):v.call(a)},this.info=function(e){var t={size:m,vertical:s.vertical,scrollPos:g,scrollDirection:p,container:s.container,isDocument:u};return arguments.length?void 0===t[e]?void N(1,"ERROR: option \""+e+"\" is not available"):t[e]:t},this.loglevel=function(e){return arguments.length?(s.loglevel!=e&&(s.loglevel=e),a):s.loglevel},this.enabled=function(e){return arg