T45c Site · Home: full screen stops the glide at once, a starting gallery leaves the host's focus alone, a focused frame stays mounted
This commit is contained in:
1 parent
d7dbcfbb18
commit
9ea811d4e8
7 files changed
+55
-17
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import Lenis from "lenis";
|
||||
import "lenis/dist/lenis.css";
|
||||
|
||||
let lenis: Lenis | null = null;
|
||||
|
||||
/** Smooth scroll for the page; the returned call ends it. */
|
||||
export function smooth(): { lenis: Lenis; end: () => void } {
|
||||
if (lenis) throw new Error("scroll: smooth scroll already runs");
|
||||
const own = new Lenis({ autoRaf: true });
|
||||
lenis = own;
|
||||
return { lenis: own, end: () => (own.destroy(), (lenis = null)) };
|
||||
}
|
||||
|
||||
/** Holds the page still at once, a glide in flight included. */
|
||||
export function hold(still: boolean): void {
|
||||
if (still) lenis?.stop();
|
||||
else lenis?.start();
|
||||
}
|
||||
Reference in new issue
Block a user