fix scroll smooth

This commit is contained in:
2026-06-04 14:51:13 +05:30
parent 123092f4b8
commit b2d64bd335
15 changed files with 331 additions and 167 deletions

View File

@@ -66,13 +66,34 @@ export default function SmoothScroll() {
gsap.registerPlugin(ScrollTrigger);
const lenis = new Lenis({
duration: 1.05,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: "vertical",
gestureOrientation: "vertical",
smoothWheel: true,
});
// /miletruth is one long stack of tall, pinned 3D sections, each with its own
// ScrollTrigger `scrub`. The default duration-based momentum (1.05s) compounds
// with that scrub, so the wheel feels heavy, slow and disconnected. On this
// route we switch to a snappy `lerp`-based follow + a higher wheel multiplier:
// the page travels fast and stays tightly locked to the wheel, while each
// section's scrub supplies the visual smoothing. Other routes keep the softer
// duration-based feel that suits their normal content.
const isMileTruth =
pathname === "/miletruth" || pathname.startsWith("/miletruth/");
const lenis = new Lenis(
isMileTruth
? {
lerp: 0.13, // snappy follow (higher = less smoothing lag)
wheelMultiplier: 1.3, // travel further per wheel tick → fast
touchMultiplier: 1.6,
orientation: "vertical",
gestureOrientation: "vertical",
smoothWheel: true,
}
: {
duration: 1.05,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: "vertical",
gestureOrientation: "vertical",
smoothWheel: true,
},
);
if (!window.location.hash) {
lenis.scrollTo(0, { immediate: true });