Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 27 lines 646 B view raw
1import type { RefObject } from "react"; 2import { useCallback, useEffect } from "react"; 3 4const usePreventScrollOnNumberInput = ( 5 ref: RefObject<HTMLInputElement> 6): void => { 7 const preventScroll = useCallback((event: WheelEvent) => { 8 event.preventDefault(); 9 event.stopPropagation(); 10 }, []); 11 12 useEffect(() => { 13 const input = ref.current; 14 15 if (input) { 16 input.addEventListener("wheel", preventScroll, { passive: false }); 17 } 18 19 return () => { 20 if (input) { 21 input.removeEventListener("wheel", preventScroll); 22 } 23 }; 24 }, [ref, preventScroll]); 25}; 26 27export default usePreventScrollOnNumberInput;