Zap modal (#209)

This commit is contained in:
Alejandro
2023-02-07 14:32:32 +01:00
committed by GitHub
parent 41aa93a279
commit 1e76e729f7
18 changed files with 403 additions and 159 deletions

View File

@ -0,0 +1,22 @@
import { useEffect, useRef, WheelEvent, LegacyRef } from "react";
function useHorizontalScroll() {
const elRef = useRef<HTMLDivElement>();
useEffect(() => {
const el = elRef.current;
if (el) {
const onWheel = (ev: WheelEvent) => {
if (ev.deltaY == 0) return;
ev.preventDefault();
el.scrollTo({ left: el.scrollLeft + ev.deltaY, behavior: "smooth" });
};
// @ts-ignore
el.addEventListener("wheel", onWheel);
// @ts-ignore
return () => el.removeEventListener("wheel", onWheel);
}
}, []);
return elRef as LegacyRef<HTMLDivElement> | undefined
}
export default useHorizontalScroll;