Files
uldp.edu.vn/public/assets/js/lenis.min.js
r2xrzh9q2z-lab d53d4417b2 Initial commit
2026-02-02 11:00:08 +07:00

1 line
12 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).Lenis=e()}(this,function(){function o(t,e){for(var i,o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,"symbol"==typeof(i=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);t=e.call(t,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(n.key))?i:String(i),n)}}function i(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function b(){return(b=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i,o=arguments[e];for(i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t}).apply(this,arguments)}function d(t,e,i){return Math.max(t,Math.min(e,i))}var z=function(){function t(){}var e=t.prototype;return e.advance=function(t){var e,i,o;this.isRunning&&(i=!1,this.lerp?(this.value=(1-(e=this.lerp))*this.value+e*this.to,Math.round(this.value)===this.to&&(this.value=this.to,i=!0)):(this.currentTime+=t,o=(i=1<=(o=d(0,this.currentTime/this.duration,1)))?1:this.easing(o),this.value=this.from+(this.to-this.from)*o),null==(o=this.onUpdate)||o.call(this,this.value,{completed:i}),i&&this.stop())},e.stop=function(){this.isRunning=!1},e.fromTo=function(t,e,i){var o=i.lerp,n=void 0===o?.1:o,s=i.duration,o=void 0===s?1:s,s=i.easing,s=void 0===s?function(t){return t}:s,i=i.onUpdate;this.from=this.value=t,this.to=e,this.lerp=n,this.duration=o,this.easing=s,this.currentTime=0,this.isRunning=!0,this.onUpdate=i},t}();function n(i,o){var n;return function(){var t=arguments,e=this;clearTimeout(n),n=setTimeout(function(){i.apply(e,t)},o)}}var M=function(){function t(t,e){var i=this;this.onWindowResize=function(){i.width=window.innerWidth,i.height=window.innerHeight},this.onWrapperResize=function(){i.width=i.wrapper.clientWidth,i.height=i.wrapper.clientHeight},this.onContentResize=function(){var t=i.wrapper===window?document.documentElement:i.wrapper;i.scrollHeight=t.scrollHeight,i.scrollWidth=t.scrollWidth},this.wrapper=t,this.content=e,this.wrapper===window?(window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize()):(this.wrapperResizeObserver=new ResizeObserver(n(this.onWrapperResize,100)),this.wrapperResizeObserver.observe(this.wrapper),this.onWrapperResize()),this.contentResizeObserver=new ResizeObserver(n(this.onContentResize,100)),this.contentResizeObserver.observe(this.content),this.onContentResize()}return t.prototype.destroy=function(){var t;window.removeEventListener("resize",this.onWindowResize,!1),null==(t=this.wrapperResizeObserver)||t.disconnect(),null==(t=this.contentResizeObserver)||t.disconnect()},i(t,[{key:"limit",get:function(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}]),t}(),E=function(){function t(t,e){var s=this,i=e.wheelMultiplier,o=void 0===i?1:i,i=e.touchMultiplier,i=void 0===i?2:i,e=e.normalizeWheel,e=void 0!==e&&e;this.onTouchStart=function(t){var e=t.targetTouches?t.targetTouches[0]:t,t=e.clientY;s.touchStart.x=e.clientX,s.touchStart.y=t,s.lastDelta={x:0,y:0}},this.onTouchMove=function(t){var e=t.targetTouches?t.targetTouches[0]:t,i=e.clientX,o=e.clientY,n=-(i-s.touchStart.x)*s.touchMultiplier,e=-(o-s.touchStart.y)*s.touchMultiplier;s.touchStart.x=i,s.touchStart.y=o,s.lastDelta={x:n,y:e},s.emitter.emit("scroll",{type:"touch",deltaX:n,deltaY:e,event:t})},this.onTouchEnd=function(t){s.emitter.emit("scroll",{type:"touch",inertia:!0,deltaX:s.lastDelta.x,deltaY:s.lastDelta.y,event:t})},this.onWheel=function(t){var e=t.deltaX,i=t.deltaY;s.normalizeWheel&&(e=d(-100,e,100),i=d(-100,i,100)),s.emitter.emit("scroll",{type:"wheel",deltaX:e*=s.wheelMultiplier,deltaY:i*=s.wheelMultiplier,event:t})},this.element=t,this.wheelMultiplier=o,this.touchMultiplier=i,this.normalizeWheel=e,this.touchStart={x:null,y:null},this.emitter={events:{},emit:function(t){for(var e=this.events[t]||[],i=0,o=e.length;i<o;i++)e[i].apply(e,[].slice.call(arguments,1))},on:function(e,i){var t,o=this;return null!=(t=this.events[e])&&t.push(i)||(this.events[e]=[i]),function(){var t;o.events[e]=null==(t=o.events[e])?void 0:t.filter(function(t){return i!==t})}}},this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}var e=t.prototype;return e.on=function(t,e){return this.emitter.on(t,e)},e.destroy=function(){this.emitter.events={},this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})},t}();return function(){function t(t){var r=this,e=void 0===t?{}:t,i=e.direction,o=e.gestureDirection,n=e.mouseMultiplier,s=e.smooth,l=e.wrapper,h=void 0===l?window:l,a=e.content,c=void 0===a?document.documentElement:a,u=e.wheelEventsTarget,p=void 0===u?h:u,d=e.smoothWheel,v=void 0===d?null==s||s:d,m=e.smoothTouch,f=void 0!==m&&m,g=e.syncTouch,w=void 0!==g&&g,S=e.syncTouchLerp,y=void 0===S?.1:S,T=e.touchInertiaMultiplier,t=void 0===T?35:T,l=e.duration,a=e.easing,u=void 0===a?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:a,d=e.lerp,m=void 0===d?l?null:.1:d,g=e.infinite,S=void 0!==g&&g,T=e.orientation,a=void 0===T?null!=i?i:"vertical":T,d=e.gestureOrientation,g=void 0===d?null!=o?o:"vertical":d,T=e.touchMultiplier,d=void 0===T?1:T,T=e.wheelMultiplier,T=void 0===T?null!=n?n:1:T,e=e.normalizeWheel,e=void 0!==e&&e;this.onVirtualScroll=function(t){var e=t.type,i=t.inertia,o=t.deltaX,n=t.deltaY,s=t.event;if(!s.ctrlKey){t="touch"===e,e="wheel"===e;if(!("vertical"===r.options.gestureOrientation&&0===n||"horizontal"===r.options.gestureOrientation&&0===o||t&&"vertical"===r.options.gestureOrientation&&0===r.scroll&&!r.options.infinite&&n<=0||s.composedPath().find(function(t){return null==t||null==t.hasAttribute?void 0:t.hasAttribute("data-lenis-prevent")})))if(r.isStopped||r.isLocked)s.preventDefault();else{if(r.isSmooth=(r.options.smoothTouch||r.options.syncTouch)&&t||r.options.smoothWheel&&e,!r.isSmooth)return r.isScrolling=!1,void r.animate.stop();s.preventDefault();s=n;"both"===r.options.gestureOrientation?s=Math.abs(n)>Math.abs(o)?n:o:"horizontal"===r.options.gestureOrientation&&(s=o);o=t&&r.options.syncTouch,i=t&&i&&1<Math.abs(s);i&&(s=r.velocity*r.options.touchInertiaMultiplier),r.scrollTo(r.targetScroll+s,b({programmatic:!1},o&&{lerp:i?r.syncTouchLerp:.4}))}}},this.onScroll=function(){var t;r.isScrolling||(t=r.animatedScroll,r.animatedScroll=r.targetScroll=r.actualScroll,r.velocity=0,r.direction=Math.sign(r.animatedScroll-t),r.emit())},i&&console.warn("Lenis: `direction` option is deprecated, use `orientation` instead"),o&&console.warn("Lenis: `gestureDirection` option is deprecated, use `gestureOrientation` instead"),n&&console.warn("Lenis: `mouseMultiplier` option is deprecated, use `wheelMultiplier` instead"),s&&console.warn("Lenis: `smooth` option is deprecated, use `smoothWheel` instead"),window.lenisVersion="1.0.11",h!==document.documentElement&&h!==document.body||(h=window),this.options={wrapper:h,content:c,wheelEventsTarget:p,smoothWheel:v,smoothTouch:f,syncTouch:w,syncTouchLerp:y,touchInertiaMultiplier:t,duration:l,easing:u,lerp:m,infinite:S,gestureOrientation:g,orientation:a,touchMultiplier:d,wheelMultiplier:T,normalizeWheel:e},this.dimensions=new M(h,c),this.rootElement.classList.add("lenis"),this.velocity=0,this.isStopped=!1,this.isSmooth=v||f,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.animate=new z,this.emitter={events:{},emit:function(t){for(var e=this.events[t]||[],i=0,o=e.length;i<o;i++)e[i].apply(e,[].slice.call(arguments,1))},on:function(e,i){var t,o=this;return null!=(t=this.events[e])&&t.push(i)||(this.events[e]=[i]),function(){var t;o.events[e]=null==(t=o.events[e])?void 0:t.filter(function(t){return i!==t})}}},this.options.wrapper.addEventListener("scroll",this.onScroll,{passive:!1}),this.virtualScroll=new E(p,{touchMultiplier:d,wheelMultiplier:T,normalizeWheel:e}),this.virtualScroll.on("scroll",this.onVirtualScroll)}var e=t.prototype;return e.destroy=function(){this.emitter.events={},this.options.wrapper.removeEventListener("scroll",this.onScroll,{passive:!1}),this.virtualScroll.destroy()},e.on=function(t,e){return this.emitter.on(t,e)},e.off=function(t,e){this.emitter.events[t]=null==(t=this.emitter.events[t])?void 0:t.filter(function(t){return e!==t})},e.setScroll=function(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t},e.emit=function(){this.emitter.emit("scroll",this)},e.reset=function(){this.isLocked=!1,this.isScrolling=!1,this.velocity=0,this.animate.stop()},e.start=function(){this.isStopped=!1,this.reset()},e.stop=function(){this.isStopped=!0,this.animate.stop(),this.reset()},e.raf=function(t){var e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)},e.scrollTo=function(t,e){var i,o=this,n=void 0===e?{}:e,s=n.offset,r=void 0===s?0:s,l=n.immediate,h=void 0!==l&&l,a=n.lock,c=void 0!==a&&a,e=n.duration,s=void 0===e?this.options.duration:e,l=n.easing,a=void 0===l?this.options.easing:l,e=n.lerp,l=void 0===e?!s&&this.options.lerp:e,e=n.onComplete,u=void 0===e?null:e,e=n.force,n=n.programmatic,p=void 0===n||n;if((!this.isStopped||void 0!==e&&e)&&(["top","left","start"].includes(t)?t=0:["bottom","right","end"].includes(t)?t=this.limit:("string"==typeof t?i=document.querySelector(t):null!=t&&t.nodeType&&(i=t),i&&(this.options.wrapper!==window&&(e=this.options.wrapper.getBoundingClientRect(),r-=this.isHorizontal?e.left:e.top),i=i.getBoundingClientRect(),t=(this.isHorizontal?i.left:i.top)+this.animatedScroll)),"number"==typeof t)){if(t+=r,t=Math.round(t),this.options.infinite?p&&(this.targetScroll=this.animatedScroll=this.scroll):t=d(0,t,this.limit),h)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.emit(),void(null==u||u());if(!p){if(t===this.targetScroll)return;this.targetScroll=t}this.animate.fromTo(this.animatedScroll,t,{duration:s,easing:a,lerp:l,onUpdate:function(t,e){e=e.completed;c&&(o.isLocked=!0),o.isScrolling=!0,o.velocity=t-o.animatedScroll,o.direction=Math.sign(o.velocity),o.animatedScroll=t,o.setScroll(o.scroll),p&&(o.targetScroll=t),e&&(c&&(o.isLocked=!1),requestAnimationFrame(function(){o.isScrolling=!1}),o.velocity=0,null==u||u()),o.emit()}})}},i(t,[{key:"rootElement",get:function(){return this.options.wrapper===window?this.options.content:this.options.wrapper}},{key:"limit",get:function(){return this.isHorizontal?this.dimensions.limit.x:this.dimensions.limit.y}},{key:"isHorizontal",get:function(){return"horizontal"===this.options.orientation}},{key:"actualScroll",get:function(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}},{key:"scroll",get:function(){return this.options.infinite?(e=this.animatedScroll%(t=this.limit),(0<t&&e<0||t<0&&0<e)&&(e+=t),e):this.animatedScroll;var t,e}},{key:"progress",get:function(){return 0===this.limit?1:this.scroll/this.limit}},{key:"isSmooth",get:function(){return this.__isSmooth},set:function(t){this.__isSmooth!==t&&(this.rootElement.classList.toggle("lenis-smooth",t),this.__isSmooth=t)}},{key:"isScrolling",get:function(){return this.__isScrolling},set:function(t){this.__isScrolling!==t&&(this.rootElement.classList.toggle("lenis-scrolling",t),this.__isScrolling=t)}},{key:"isStopped",get:function(){return this.__isStopped},set:function(t){this.__isStopped!==t&&(this.rootElement.classList.toggle("lenis-stopped",t),this.__isStopped=t)}}]),t}()});