UNPKG

rsuite

Version:

A suite of react components

20 lines (19 loc) 469 B
'use client'; import { useEffect } from 'react'; import on from 'dom-lib/on'; /** * Attach wheel listener to inputRef. */ export function useWheelHandler(inputRef, handleWheel, scrollable) { useEffect(() => { let wheelListener; if (inputRef.current) { wheelListener = on(inputRef.current, 'wheel', handleWheel, { passive: false }); } return () => { wheelListener?.off(); }; }, [inputRef, handleWheel, scrollable]); }