PageSourceSearch

https://scrollbook.ai/assets/lenis-BmJhOmId.js

js scrollbook.ai collected 2026-10-05 12:39:25 UTC 17,677 bytes, 1 lines download raw bytes

1import{t as i}from"./defineProperty-CkKLuKw5.js";var $="1.3.17";function P(t,e,s){return Math.max(t,Math.min(e,s))}function B(t,e,s){return(1-s)*t+s*e}function G(t,e,s,n){return B(t,e,1-Math.exp(-s*n))}function j(t,e){return(t%e+e)%e}var K=class{constructor(){i(this,"isRunning",!1),i(this,"value",0),i(this,"from",0),i(this,"to",0),i(this,"currentTime",0),i(this,"lerp",void 0),i(this,"duration",void 0),i(this,"easing",void 0),i(this,"onUpdate",void 0)}advance(t){if(!this.isRunning)return;let e=!1;if(this.duration&&this.easing){this.currentTime+=t;const s=P(0,this.currentTime/this.duration,1);e=s>=1;const n=e?1:this.easing(s);this.value=this.from+(this.to-this.from)*n}else this.lerp?(this.value=G(this.value,this.to,this.lerp*60,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0)):(this.value=this.to,e=!0);e&&this.stop(),this.onUpdate?.(this.value,e)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:s,duration:n,easing:o,onStart:l,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=s,this.duration=n,this.easing=o,this.currentTime=0,this.isRunning=!0,l?.(),this.onUpdate=r}};function J(t,e){let s;return function(...n){let o=this;clearTimeout(s),s=setTimeout(()=>{s=void 0,t.apply(o,n)},e)}}var Q=class{constructor(t,e,{autoResize:s=!0,debounce:n=250}={}){i(this,"width",0),i(this,"height",0),i(this,"scrollHeight",0),i(this,"scrollWidth",0),i(this,"debouncedResize",void 0),i(this,"wrapperResizeObserver",void 0),i(this,"contentResizeObserver",void 0),i(this,"resize",()=>{this.onWrapperResize(),this.onContentResize()}),i(this,"onWrapperResize",()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)}),i(this,"onContentResize",()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)}),this.wrapper=t,this.content=e,s&&(this.debouncedResize=J(this.resize,n),this.wrapper instanceof Window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},A=class{constructor(){i(this,"events",{})}emit(t,...e){let s=this.events[t]||[];for(let n=0,o=s.length;n<o;n++)s[n]?.(...e)}on(t,e){return this.events[t]?.push(e)||(this.events[t]=[e]),()=>{this.events[t]=this.events[t]?.filter(s=>e!==s)}}off(t,e){this.events[t]=this.events[t]?.filter(s=>e!==s)}destroy(){this.events={}}},X=100/6,y={passive:!1},Z=class{constructor(t,e={wheelMultiplier:1,touchMultiplier:1}){i(this,"touchStart",{x:0,y:0}),i(this,"lastDelta",{x:0,y:0}),i(this,"window",{width:0,height:0}),i(this,"emitter",new A),i(this,"onTouchStart",s=>{const{clientX:n,clientY:o}=s.targetTouches?s.targetTouches[0]:s;this.touchStart.x=n,this.touchStart.y=o,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:s})}),i(this,"onTouchMove",s=>{const{clientX:n,clientY:o}=s.targetTouches?s.targetTouches[0]:s,l=-(n-this.touchStart.x)*this.options.touchMultiplier,r=-(o-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=n,this.touchStart.y=o,this.lastDelta={x:l,y:r},this.emitter.emit("scroll",{deltaX:l,deltaY:r,event:s})}),i(this,"onTouchEnd",s=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:s})}),i(this,"onWheel",s=>{let{deltaX:n,deltaY:o,deltaMode:l}=s;const r=l===1?X:l===2?this.window.width:1,c=l===1?X:l===2?this.window.height:1;n*=r,o*=c,n*=this.options.wheelMultiplier,o*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:n,deltaY:o,event:s})}),i(this,"onWindowResize",()=>{this.window={width:window.innerWidth,height:window.innerHeight}}),this.element=t,this.options=e,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,y),this.element.addEventListener("touchstart",this.onTouchStart,y),this.element.addEventListener("touchmove",this.onTouchMove,y),this.element.addEventListener("touchend",this.onTouchEnd,y)}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,y),this.element.removeEventListener("touchstart",this.onTouchStart,y),this.element.removeEventListener("touchmove",this.onTouchMove,y),this.element.removeEventListener("touchend",this.onTouchEnd,y)}},Y=t=>Math.min(1,1.001-Math.pow(2,-10*t)),it=class{constructor({wrapper:t=window,content:e=document.documentElement,eventsTarget:s=t,smoothWheel:n=!0,syncTouch:o=!1,syncTouchLerp:l=.075,touchInertiaExponent:r=1.7,duration:c,easing:u,lerp:S=.1,infinite:g=!1,orientation:w="vertical",gestureOrientation:a=w==="horizontal"?"both":"vertical",touchMultiplier:f=1,wheelMultiplier:m=1,autoResize:E=!0,prevent:L,virtualScroll:N,overscroll:R=!0,autoRaf:W=!1,anchors:T=!1,autoToggle:H=!1,allowNestedScroll:k=!1,__experimental__naiveDimensions:V=!1,naiveDimensions:I=V,stopInertiaOnNavigate:U=!1}={}){i(this,"_isScrolling",!1),i(this,"_isStopped",!1),i(this,"_isLocked",!1),i(this,"_preventNextNativeScrollEvent",!1),i(this,"_resetVelocityTimeout",null),i(this,"_rafId",null),i(this,"isTouching",void 0),i(this,"time",0),i(this,"userData",{}),i(this,"lastVelocity",0),i(this,"velocity",0),i(this,"direction",0),i(this,"options",void 0),i(this,"targetScroll",void 0),i(this,"animatedScroll",void 0),i(this,"animate",new K),i(this,"emitter",new A),i(this,"dimensions",void 0),i(this,"virtualScroll",void 0),i(this,"onScrollEnd",p=>{p instanceof CustomEvent||(this.isScrolling==="smooth"||this.isScrolling===!1)&&p.stopPropagation()}),i(this,"dispatchScrollendEvent",()=>{this.options.wrapper.dispatchEvent(new CustomEvent("scrollend",{bubbles:this.options.wrapper===window,detail:{lenisScrollEnd:!0}}))}),i(this,"onTransitionEnd",p=>{p.propertyName.includes("overflow")&&this.checkOverflow()}),i(this,"onClick",p=>{const v=p.composedPath().filter(d=>d instanceof HTMLAnchorElement&&d.getAttribute("href"));if(this.options.anchors){const d=v.find(h=>h.getAttribute("href")?.includes("#"));if(d){const h=d.getAttribute("href");if(h){const b=typeof this.options.anchors=="object"&&this.options.anchors?this.options.anchors:void 0,O=`#${h.split("#")[1]}`;this.scrollTo(O,b)}}}this.options.stopInertiaOnNavigate&&v.find(d=>d.host===window.location.host)&&this.reset()}),i(this,"onPointerDown",p=>{p.button===1&&this.reset()}),i(this,"onVirtualScroll",p=>{if(typeof this.options.virtualScroll=="function"&&this.options.virtualScroll(p)===!1)return;const{deltaX:v,deltaY:d,event:h}=p;if(this.emitter.emit("virtual-scroll",{deltaX:v,deltaY:d,event:h}),h.ctrlKey||h.lenisStopPropagation)return;const b=h.type.includes("touch"),O=h.type.includes("wheel");this.isTouching=h.type==="touchstart"||h.type==="touchmove";
1const M=v===0&&d===0;if(this.options.syncTouch&&b&&h.type==="touchstart"&&M&&!this.isStopped&&!this.isLocked){this.reset();return}const q=this.options.gestureOrientation==="vertical"&&d===0||this.options.gestureOrientation==="horizontal"&&v===0;if(M||q)return;let _=h.composedPath();_=_.slice(0,_.indexOf(this.rootElement));const C=this.options.prevent;if(_.find(z=>z instanceof HTMLElement&&(typeof C=="function"&&C?.(z)||z.hasAttribute?.("data-lenis-prevent")||b&&z.hasAttribute?.("data-lenis-prevent-touch")||O&&z.hasAttribute?.("data-lenis-prevent-wheel")||this.options.allowNestedScroll&&this.checkNestedScroll(z,{deltaX:v,deltaY:d}))))return;if(this.isStopped||this.isLocked){h.cancelable&&h.preventDefault();return}if(!(this.options.syncTouch&&b||this.options.smoothWheel&&O)){this.isScrolling="native",this.animate.stop(),h.lenisStopPropagation=!0;return}let x=d;this.options.gestureOrientation==="both"?x=Math.abs(d)>Math.abs(v)?d:v:this.options.gestureOrientation==="horizontal"&&(x=v),(!this.options.overscroll||this.options.infinite||this.options.wrapper!==window&&this.limit>0&&(this.animatedScroll>0&&this.animatedScroll<this.limit||this.animatedScroll===0&&d>0||this.animatedScroll===this.limit&&d<0))&&(h.lenisStopPropagation=!0),h.cancelable&&h.preventDefault();const F=b&&this.options.syncTouch,D=b&&h.type==="touchend";D&&(x=Math.sign(this.velocity)*Math.pow(Math.abs(this.velocity),this.options.touchInertiaExponent)),this.scrollTo(this.targetScroll+x,{programmatic:!1,...F?{lerp:D?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}})}),i(this,"onNativeScroll",()=>{if(this._resetVelocityTimeout!==null&&(clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null),this._preventNextNativeScrollEvent){this._preventNextNativeScrollEvent=!1;return}if(this.isScrolling===!1||this.isScrolling==="native"){const p=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-p,this.direction=Math.sign(this.animatedScroll-p),this.isStopped||(this.isScrolling="native"),this.emit(),this.velocity!==0&&(this._resetVelocityTimeout=setTimeout(()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()},400))}}),i(this,"raf",p=>{const v=p-(this.time||p);this.time=p,this.animate.advance(v*.001),this.options.autoRaf&&(this._rafId=requestAnimationFrame(this.raf))}),window.lenisVersion=$,(!t||t===document.documentElement)&&(t=window),typeof c=="number"&&typeof u!="function"?u=Y:typeof u=="function"&&typeof c!="number"&&(c=1),this.options={wrapper:t,content:e,eventsTarget:s,smoothWheel:n,syncTouch:o,syncTouchLerp:l,touchInertiaExponent:r,duration:c,easing:u,lerp:S,infinite:g,gestureOrientation:a,orientation:w,touchMultiplier:f,wheelMultiplier:m,autoResize:E,prevent:L,virtualScroll:N,overscroll:R,autoRaf:W,anchors:T,autoToggle:H,allowNestedScroll:k,naiveDimensions:I,stopInertiaOnNavigate:U},this.dimensions=new Q(t,e,{autoResize:E}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("scrollend",this.onScrollEnd,{capture:!0}),(this.options.anchors||this.options.stopInertiaOnNavigate)&&this.options.wrapper.addEventListener("click",this.onClick,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new Z(s,{touchMultiplier:f,wheelMultiplier:m}),this.virtualScroll.on("scroll",this.onVirtualScroll),this.options.autoToggle&&(this.checkOverflow(),this.rootElement.addEventListener("transitionend",this.onTransitionEnd,{passive:!0})),this.options.autoRaf&&(this._rafId=requestAnimationFrame(this.raf))}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),(this.options.anchors||this.options.stopInertiaOnNavigate)&&this.options.wrapper.removeEventListener("click",this.onClick,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName(),this._rafId&&cancelAnimationFrame(this._rafId)}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}get overflow(){const t=this.isHorizontal?"overflow-x":"overflow-y";return getComputedStyle(this.rootElement)[t]}checkOverflow(){["hidden","clip"].includes(this.overflow)?this.internalStop():this.internalStart()}setScroll(t){this.isHorizontal?this.options.wrapper.scrollTo({left:t,behavior:"instant"}):this.options.wrapper.scrollTo({top:t,behavior:"instant"})}resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit
1()}emit(){this.emitter.emit("scroll",this)}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){if(this.isStopped){if(this.options.autoToggle){this.rootElement.style.removeProperty("overflow");return}this.internalStart()}}internalStart(){this.isStopped&&(this.reset(),this.isStopped=!1,this.emit())}stop(){if(!this.isStopped){if(this.options.autoToggle){this.rootElement.style.setProperty("overflow","clip");return}this.internalStop()}}internalStop(){this.isStopped||(this.reset(),this.isStopped=!0,this.emit())}scrollTo(t,{offset:e=0,immediate:s=!1,lock:n=!1,programmatic:o=!0,lerp:l=o?this.options.lerp:void 0,duration:r=o?this.options.duration:void 0,easing:c=o?this.options.easing:void 0,onStart:u,onComplete:S,force:g=!1,userData:w}={}){if(!((this.isStopped||this.isLocked)&&!g)){if(typeof t=="string"&&["top","left","start","#"].includes(t))t=0;else if(typeof t=="string"&&["bottom","right","end"].includes(t))t=this.limit;else{let a;if(typeof t=="string"?(a=document.querySelector(t),a||(t==="#top"?t=0:console.warn("Lenis: Target not found",t))):t instanceof HTMLElement&&t?.nodeType&&(a=t),a){if(this.options.wrapper!==window){const m=this.rootElement.getBoundingClientRect();e-=this.isHorizontal?m.left:m.top}const f=a.getBoundingClientRect();t=(this.isHorizontal?f.left:f.top)+this.animatedScroll}}if(typeof t=="number"){if(t+=e,t=Math.round(t),this.options.infinite){if(o){this.targetScroll=this.animatedScroll=this.scroll;const a=t-this.animatedScroll;a>this.limit/2?t=t-this.limit:a<-this.limit/2&&(t=t+this.limit)}}else t=P(0,t,this.limit);if(t===this.targetScroll){u?.(this),S?.(this);return}if(this.userData=w??{},s){this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),S?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()});return}o||(this.targetScroll=t),typeof r=="number"&&typeof c!="function"?c=Y:typeof c=="function"&&typeof r!="number"&&(r=1),this.animate.fromTo(this.animatedScroll,t,{duration:r,easing:c,lerp:l,onStart:()=>{n&&(this.isLocked=!0),this.isScrolling="smooth",u?.(this)},onUpdate:(a,f)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=a-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=a,this.setScroll(this.scroll),o&&(this.targetScroll=a),f||this.emit(),f&&(this.reset(),this.emit(),S?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()}),this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame(()=>{this._preventNextNativeScrollEvent=!1})}checkNestedScroll(t,{deltaX:e,deltaY:s}){const n=Date.now(),o=t._lenis??(t._lenis={});let l,r,c,u,S,g,w,a;const f=this.options.gestureOrientation;if(n-(o.time??0)>2e3){o.time=Date.now();const T=window.getComputedStyle(t);o.computedStyle=T;const H=T.overflowX,k=T.overflowY;if(l=["auto","overlay","scroll"].includes(H),r=["auto","overlay","scroll"].includes(k),o.hasOverflowX=l,o.hasOverflowY=r,!l&&!r||f==="vertical"&&!r||f==="horizontal"&&!l)return!1;S=t.scrollWidth,g=t.scrollHeight,w=t.clientWidth,a=t.clientHeight,c=S>w,u=g>a,o.isScrollableX=c,o.isScrollableY=u,o.scrollWidth=S,o.scrollHeight=g,o.clientWidth=w,o.clientHeight=a}else c=o.isScrollableX,u=o.isScrollableY,l=o.hasOverflowX,r=o.hasOverflowY,S=o.scrollWidth,g=o.scrollHeight,w=o.clientWidth,a=o.clientHeight;if(!l&&!r||!c&&!u||f==="vertical"&&(!r||!u)||f==="horizontal"&&(!l||!c))return!1;let m;if(f==="horizontal")m="x";else if(f==="vertical")m="y";else{const T=e!==0,H=s!==0;T&&l&&c&&(m="x"),H&&r&&u&&(m="y")}if(!m)return!1;let E,L,N,R,W;if(m==="x")E=t.scrollLeft,L=S-w,N=e,R=l,W=c;else if(m==="y")E=t.scrollTop,L=g-a,N=s,R=r,W=u;else return!1;return(N>0?E<L:E>0)&&R&&W}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return this.options.orientation==="horizontal"}get actualScroll(){const t=this.options.wrapper;return this.isHorizontal?t.scrollX??t.scrollLeft:t.scrollY??t.scrollTop}get scroll(){return this.options.infinite?j(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return this.limit===0?1:this.scroll/this.limit}get isScrolling(){return this._isScrolling}set isScrolling(t){this._isScrolling!==t&&(this._isScrolling=t,this.updateClassName())}get isStopped(){return this._isStopped}set isStopped(t){this._isStopped!==t&&(this._isStopped=t,this.updateClassName())}get isLocked(){return this._isLocked}set isLocked(t){this._isLocked!==t&&(this._isLocked=t,this.updateClassName())}get isSmooth(){return this.isScrolling==="smooth"}get className(){let t="lenis";return this.options.autoToggle&&(t+=" lenis-autoToggle"),this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),this.isScrolling==="smooth"&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}};export{it as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.