mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-13 17:47:39 +01:00
23 lines
597 B
TypeScript
23 lines
597 B
TypeScript
import { useEffect } from '../lib/teact/teact';
|
|
|
|
export default (container: HTMLElement | null, isDisabled?: boolean) => {
|
|
useEffect(() => {
|
|
if (!container) {
|
|
return undefined;
|
|
}
|
|
|
|
function handleScroll(e: WheelEvent) {
|
|
// Ignore horizontal scroll and let it work natively (e.g. on touchpad)
|
|
if (!e.deltaX) {
|
|
container!.scrollLeft += e.deltaY / 4;
|
|
}
|
|
}
|
|
|
|
container.addEventListener('wheel', handleScroll, { passive: true });
|
|
|
|
return () => {
|
|
container.removeEventListener('wheel', handleScroll);
|
|
};
|
|
}, [container, isDisabled]);
|
|
};
|