Skip to content

Commit f030fa0

Browse files
committed
Add Lenis smooth scrolling to landing
1 parent 8b613f8 commit f030fa0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/homepage/useScrollytelling.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useRef, useState } from "react";
2+
import { smoothScrollTo } from "./smoothScroll";
23

34
/**
45
* Native sticky scrollytelling.
@@ -86,10 +87,10 @@ export function useScrollytelling<T extends HTMLElement>(
8687
globalThis.window?.matchMedia &&
8788
globalThis.window.matchMedia("(prefers-reduced-motion: reduce)").matches,
8889
);
89-
window.scrollTo({
90-
top: el.offsetTop + (travel * (index + 0.5)) / stepCount,
91-
behavior: reduceMotion ? "auto" : "smooth",
92-
});
90+
smoothScrollTo(
91+
el.offsetTop + (travel * (index + 0.5)) / stepCount,
92+
reduceMotion ? "auto" : "smooth",
93+
);
9394
};
9495

9596
return { ref, active, goToStep };

0 commit comments

Comments
 (0)