Smooth scroll
Register SmoothScroll under the smooth key before initialization.
Usage
<html data-lg-smooth>
import { Luge, SmoothScroll } from '@waaark/luge'
import '@waaark/luge/css'
const luge = new Luge()
luge.addPlugin('smooth', SmoothScroll)
luge.init()
When enabled and <html data-lg-smooth> is present, luge creates one Lenis instance, adds has-smooth-scroll to <html>, and drives Lenis through its ticker. The instance is available as luge.smoothscroll.lenis after siteInit, not necessarily immediately after calling init():
// Register before luge.init(). The plugin may be disabled on this device.
luge.emitter.once('afterSiteInit', () => {
const lenis = luge.smoothscroll.lenis
if (lenis) lenis.scrollTo(0, { immediate: true })
})
Luge constructs Lenis with its defaults. smooth.inertia remains in the settings object for compatibility but is not passed to Lenis. Do not rely on it to tune scrolling.
Scroll event
luge.emitter.on('scroll', callback) observes scroll updates. Globals include window.scrollTop, its compatibility alias window.unifiedScrollTop, window.maxScrollTop, window.scrollProgress, and window.hasSmoothScroll.
Module users choose device-disable conditions explicitly. The UMD bundle disables smooth scrolling on tablet/mobile and Safari 12 or earlier. See disabling plugins.
When using an external ticker, forward a timestamp in milliseconds; Lenis requires it.