11 lines
10 KiB
JavaScript
11 lines
10 KiB
JavaScript
|
|
/*!
|
||
|
|
* ScrollSmoother 3.10.4
|
||
|
|
* https://greensock.com
|
||
|
|
*
|
||
|
|
* @license Copyright 2022, GreenSock. All rights reserved.
|
||
|
|
* This plugin is a membership benefit of Club GreenSock and is only authorized for use in sites/apps/products developed by individuals/companies with an active Club GreenSock membership. See https://greensock.com/club
|
||
|
|
* @author: Jack Doyle, jack@greensock.com
|
||
|
|
*/
|
||
|
|
|
||
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function q(){return"undefined"!=typeof window}function r(){return B||q()&&(B=window.gsap)&&B.registerPlugin&&B}var B,H,F,z,M,I,U,D,L,N,O,V,j,t=(ScrollSmoother.register=function register(e){return H||(B=e||r(),q()&&window.document&&(F=window,z=document,M=z.documentElement,I=z.body),B&&(U=B.utils.toArray,D=B.utils.clamp,O=B.parseEase("expo"),L=B.core.globals().ScrollTrigger,B.core.globals("ScrollSmoother",ScrollSmoother),I&&L&&(V=L.core._getVelocityProp,j=L.core._inputObserver,ScrollSmoother.refresh=L.refresh,H=1))),H},function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}(ScrollSmoother,[{key:"progress",get:function get(){return this.scrollTrigger.animation._time/100}}]),ScrollSmoother);function ScrollSmoother(e){var o=this;H||ScrollSmoother.register(B)||console.warn("Please gsap.registerPlugin(ScrollSmoother)"),e=this.vars=e||{},N&&N.kill(),N=this;function ra(){return _.update(-k)}function ta(){return n.style.overflow="visible"}function va(e){e.update();var t=e.getTween();t&&(t.pause(),t._time=t._dur,t._tTime=t._tDur),h=!1,e.animation.progress(e.progress,!0)}function wa(e,t){(e!==k&&!u||t)&&(E&&(n.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+e+", 0, 1)"),C=e-k,k=e,L.isUpdating||L.update())}function xa(e){return arguments.length?(u?k=-e:wa(-e),R.y=-e,h=!0,x(e),this):-k-x.offset}function za(e){m.scrollTop=0,S&&!1===S(o,e)||(L.isInViewport(e.target)||e.target===d||o.scrollTo(e.target,!1,"center center"),d=e.target)}function Aa(e){var r,n,o,i;w.forEach(function(t){r=t.pins,i=t.markers,e.forEach(function(e){e.trigger!==t.trigger&&e.pinnedContainer!==t.trigger||t===e||(n=e.start,o=(n-t.start-t.offset)/t.ratio-(n-t.start),r.forEach(function(e){return o-=e.distance/t.ratio-e.distance}),e.setPositions(n+o,e.end+o),e.markerStart&&i.push(B.quickSetter([e.markerStart,e.markerEnd],"y","px")),e.pin&&0<e.end&&(o=e.end-e.start,r.push({start:e.start,end:e.end,distance:o,trig:e}),t.setPositions(t.start,t.end+o),t.vars.onRefresh(t)))})})}function Ba(){ta(),requestAnimationFrame(ta),w&&(w.forEach(function(e){var t=e.start,r=e.auto?Math.min(L.maxScroll(e.scroller),e.end):t+(e.end-t)/e.ratio,n=(r-e.end)/2;t-=n,r-=n,e.offset=n||1e-4,e.pins.length=0,e.setPositions(Math.min(t,r),Math.max(t,r)),e.vars.onRefresh(e)}),Aa(L.sort())),_.reset()}function Ca(){return w&&w.forEach(function(e){return e.vars.onRefresh(e)})}function Da(){return w&&w.forEach(function(e){return e.vars.onRefreshInit(e)}),Ca}function Ea(t,r,n,o){return function(){var e="function"==typeof r?r(n,o):r;return e||0===e||(e=o.getAttribute("data-"+t)||("speed"===t?1:0)),o.setAttribute("data-"+t,e),"auto"===e?e:parseFloat(e)}}function Fa(r,e,t,n){function tb(){e=s(),t=f(),o=parseFloat(e)||1,c=(a="auto"===e)?0:.5,l&&l.kill(),l=t&&B.to(r,{ease:O,overwrite:!1,y:"+=0",duration:t}),i&&(i.ratio=o,i.autoSpeed=a)}function ub(){d.y=h+"px",d.renderTransform(1),tb()}function yb(e){if(a){ub();var t=function _autoDistance(e,t){var r,n,o=e.parentNode||M,i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=s.top-i.top,l=s.bottom-i.bottom,c=(Math.abs(a)>Math.abs(l)?a:l)/(1-t),u=-c*t;return 0<c&&(u+=-(n=.5==(r=s.height/(F.innerHeight+s.height))?2*s.height:2*Math.min(s.height,-c*r/(2*r-1)))/2,c+=n),{change:c,offset:u}}(r,D(0,1,-e.start/(e.end-e.start)));v=t.change,u=t.offset}else v=(e.end-e.start)*(1-o),u=0;g.forEach(function(e){return v-=e.distance*(1-o)}),e.vars.onUpdate(e),l&&l.progress(1)}var o,i,a,l,c,u,s=Ea("speed",e,n,r),f=Ea("lag",t,n,r),h=B.getProperty(r,"y"),d=r._gsap,g=[],p=[],v=0;return tb(),(1!==o||a||l)&&(yb(i=L.create({trigger:a?r.parentNode:r,scroller:m,scrub:!0,refreshPriority:-999,onRefreshInit:ub,onRefresh:yb,onKill:function onKill(
|