12 lines
11 KiB
JavaScript
12 lines
11 KiB
JavaScript
|
|
/*!
|
||
|
|
* ScrollSmoother 3.11.0
|
||
|
|
* 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 A||q()&&(A=window.gsap)&&A.registerPlugin&&A}var A,F,I,M,D,L,O,U,N,V,j,Y,G,t=(ScrollSmoother.register=function register(e){return F||(A=e||r(),q()&&window.document&&(I=window,M=document,D=M.documentElement,L=M.body),A&&(O=A.utils.toArray,U=A.utils.clamp,j=A.parseEase("expo"),N=A.core.globals().ScrollTrigger,A.core.globals("ScrollSmoother",ScrollSmoother),L&&N&&(Y=N.core._getVelocityProp,G=N.core._inputObserver,ScrollSmoother.refresh=N.refresh,F=1))),F},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?this.scrollTrigger.animation._time/100:0}}]),ScrollSmoother);function ScrollSmoother(e){var o=this;F||ScrollSmoother.register(A)||console.warn("Please gsap.registerPlugin(ScrollSmoother)"),e=this.vars=e||{},V&&V.kill(),V=this;function ta(){return B.update(-P)}function va(){return n.style.overflow="visible"}function xa(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 ya(e,t){(e!==P&&!u||t)&&(k&&(n.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+e+", 0, 1)",n._gsap.y=e+"px"),R=e-P,P=e,N.isUpdating||N.update())}function za(e){return arguments.length?(e<0&&(e=0),H.y=-e,h=!0,u?P=-e:ya(-e),C(e),this):-P}function Ba(e){m.scrollTop=0,e.target.contains&&e.target.contains(m)||S&&!1===S(o,e)||(N.isInViewport(e.target)||e.target===g||o.scrollTo(e.target,!1,"center center"),g=e.target)}function Ca(e){var r,n,o,i;b.forEach(function(t){r=t.pins,i=t.markers,e.forEach(function(e){t.trigger&&e.trigger&&t!==e&&(e.trigger===t.trigger||e.pinnedContainer===t.trigger||t.trigger.contains(e.trigger))&&(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(A.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 Da(){va(),requestAnimationFrame(va),b&&(b.forEach(function(e){var t=e.start,r=e.auto?Math.min(N.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)}),Ca(N.sort())),B.reset()}function Ea(){return N.addEventListener("refresh",Da)}function Fa(){return b&&b.forEach(function(e){return e.vars.onRefresh(e)})}function Ga(){return b&&b.forEach(function(e){return e.vars.onRefreshInit(e)}),Fa}function Ha(t,r,n,o){return function(){var e="function"==typeof r?r(n,o):r;return e||0===e||(e=o.getAttribute("data-"+E+t)||("speed"===t?1:0)),o.setAttribute("data-"+E+t,e),"auto"===e?e:parseFloat(e)}}function Ia(r,e,t,n){function wb(){e=s(),t=f(),o=parseFloat(e)||1,c=(a="auto"===e)?0:.5,l&&l.kill(),l=t&&A.to(r,{ease:j,overwrite:!1,y:"+=0",duration:t}),i&&(i.ratio=o,i.autoSpeed=a)}function xb(){g.y=h+"px",g.renderTransform(1),wb()}function Bb(e){if(a){xb();var t=function _autoDistance(e,t){var r,n,o=e.parentNode||D,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&&(n=.5==(r=s.height/(I.innerHeight+s.height))?2*s.height:2*Math.min(s.height,-c*r/(2*r-1))*(t||1),u+=t?-n*t:-n/2,c+=n),{change:c,offset:u}}(r,U(0,1,-e.start/(e.end-e.start)));v=t.change,u=t.offset}else v=(e.end-e.start)*(1-o),u=0;d.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=Ha("speed",e,n,r),f=Ha("lag",t,n,r),h
|
||
|
|
|