mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-26 13:47:03 +02:00
Listen on timeline ref instead of window (#18006)
This commit is contained in:
parent
1a383c47b5
commit
5c3ac75c31
@ -159,16 +159,30 @@ export function useTimelineZoom({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener("wheel", handleWheel, { passive: false });
|
const timelineElement = timelineRef.current;
|
||||||
window.addEventListener("touchstart", handleTouchStart, { passive: false });
|
|
||||||
window.addEventListener("touchmove", handleTouchMove, { passive: false });
|
if (timelineElement) {
|
||||||
|
timelineElement.addEventListener("wheel", handleWheel, {
|
||||||
|
passive: false,
|
||||||
|
});
|
||||||
|
timelineElement.addEventListener("touchstart", handleTouchStart, {
|
||||||
|
passive: false,
|
||||||
|
});
|
||||||
|
timelineElement.addEventListener("touchmove", handleTouchMove, {
|
||||||
|
passive: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("wheel", handleWheel);
|
if (timelineElement) {
|
||||||
window.removeEventListener("touchstart", handleTouchStart);
|
timelineElement.removeEventListener("wheel", handleWheel);
|
||||||
window.removeEventListener("touchmove", handleTouchMove);
|
timelineElement.removeEventListener("touchstart", handleTouchStart);
|
||||||
|
timelineElement.removeEventListener("touchmove", handleTouchMove);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, [handleWheel, handleTouchStart, handleTouchMove]);
|
// we know that these deps are correct
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [handleWheel, handleTouchStart, handleTouchMove, timelineRef.current]);
|
||||||
|
|
||||||
return { zoomLevel, handleZoom, isZooming, zoomDirection };
|
return { zoomLevel, handleZoom, isZooming, zoomDirection };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user