1 parent 8b613f8 commit f030fa0Copy full SHA for f030fa0
1 file changed
src/homepage/useScrollytelling.ts
@@ -1,4 +1,5 @@
1
import { useEffect, useRef, useState } from "react";
2
+import { smoothScrollTo } from "./smoothScroll";
3
4
/**
5
* Native sticky scrollytelling.
@@ -86,10 +87,10 @@ export function useScrollytelling<T extends HTMLElement>(
86
87
globalThis.window?.matchMedia &&
88
globalThis.window.matchMedia("(prefers-reduced-motion: reduce)").matches,
89
);
- window.scrollTo({
90
- top: el.offsetTop + (travel * (index + 0.5)) / stepCount,
91
- behavior: reduceMotion ? "auto" : "smooth",
92
- });
+ smoothScrollTo(
+ el.offsetTop + (travel * (index + 0.5)) / stepCount,
+ reduceMotion ? "auto" : "smooth",
93
+ );
94
};
95
96
return { ref, active, goToStep };
0 commit comments