MCPcopy
hub / github.com/darkroomengineering/lenis / constructor

Method constructor

packages/core/src/lenis.ts:101–232  ·  view source on GitHub ↗
({
    wrapper = window,
    content = document.documentElement,
    eventsTarget = wrapper,
    smoothWheel = true,
    syncTouch = false,
    syncTouchLerp = 0.075,
    touchInertiaExponent = 1.7,
    duration, // in seconds
    easing,
    lerp = 0.1,
    infinite = false,
    orientation = 'vertical', // vertical, horizontal
    gestureOrientation = orientation === 'horizontal' ? 'both' : 'vertical', // vertical, horizontal, both
    touchMultiplier = 1,
    wheelMultiplier = 1,
    autoResize = true,
    prevent,
    virtualScroll,
    overscroll = true,
    autoRaf = false,
    anchors = false,
    autoToggle = false, // https://caniuse.com/?search=transition-behavior
    allowNestedScroll = false,
    __experimental__naiveDimensions = false,
    naiveDimensions = __experimental__naiveDimensions,
    stopInertiaOnNavigate = false,
  }: LenisOptions = {})

Source from the content-addressed store, hash-verified

99 private readonly virtualScroll: VirtualScroll
100
101 constructor({
102 wrapper = window,
103 content = document.documentElement,
104 eventsTarget = wrapper,
105 smoothWheel = true,
106 syncTouch = false,
107 syncTouchLerp = 0.075,
108 touchInertiaExponent = 1.7,
109 duration, // in seconds
110 easing,
111 lerp = 0.1,
112 infinite = false,
113 orientation = 'vertical', // vertical, horizontal
114 gestureOrientation = orientation === 'horizontal' ? 'both' : 'vertical', // vertical, horizontal, both
115 touchMultiplier = 1,
116 wheelMultiplier = 1,
117 autoResize = true,
118 prevent,
119 virtualScroll,
120 overscroll = true,
121 autoRaf = false,
122 anchors = false,
123 autoToggle = false, // https://caniuse.com/?search=transition-behavior
124 allowNestedScroll = false,
125 __experimental__naiveDimensions = false,
126 naiveDimensions = __experimental__naiveDimensions,
127 stopInertiaOnNavigate = false,
128 }: LenisOptions = {}) {
129 // Set version (deprecated)
130 window.lenisVersion = version
131
132 if (!window.lenis) {
133 window.lenis = {}
134 }
135
136 window.lenis.version = version
137
138 if (orientation === 'horizontal') {
139 window.lenis.horizontal = true
140 }
141
142 if (syncTouch === true) {
143 window.lenis.touch = true
144 }
145
146 this.isIos = /(iPad|iPhone|iPod)/g.test(navigator.userAgent)
147
148 // Check if wrapper is <html>, fallback to window
149 if (!wrapper || wrapper === document.documentElement) {
150 wrapper = window
151 }
152
153 // flip to easing/time based animation if at least one of them is provided
154 if (typeof duration === 'number' && typeof easing !== 'function') {
155 easing = defaultEasing
156 } else if (typeof easing === 'function' && typeof duration !== 'number') {
157 duration = 1
158 }

Callers

nothing calls this directly

Calls 3

updateClassNameMethod · 0.95
checkOverflowMethod · 0.95
onMethod · 0.45

Tested by

no test coverage detected