fix: Media Explorer canvas wheel dùng native non-passive listener
This commit is contained in:
+12
-1
@@ -9126,6 +9126,18 @@ const MediaExplorerPanel = ({ height, clipboardRef }) => {
|
||||
setZoom(prev => Math.max(0.2, prev / zoomFactor));
|
||||
}
|
||||
};
|
||||
// React attaches onWheel passively at the root, so e.preventDefault() there is
|
||||
// ignored and Chrome logs "Unable to preventDefault inside passive event listener".
|
||||
// Use a native non-passive wheel listener so page scroll is actually blocked.
|
||||
const handleCanvasWheelRef = React.useRef(handleCanvasWheel);
|
||||
handleCanvasWheelRef.current = handleCanvasWheel;
|
||||
React.useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
const h = (e) => handleCanvasWheelRef.current(e);
|
||||
canvas.addEventListener('wheel', h, { passive: false });
|
||||
return () => canvas.removeEventListener('wheel', h);
|
||||
}, []);
|
||||
|
||||
const handleCanvasMouseDown = (e) => {
|
||||
if (!selected) return;
|
||||
@@ -10509,7 +10521,6 @@ const MediaExplorerPanel = ({ height, clipboardRef }) => {
|
||||
onMouseMove={handleCanvasMouseMove}
|
||||
onMouseUp={handleCanvasMouseUp}
|
||||
onContextMenu={handleCanvasContextMenu}
|
||||
onWheel={handleCanvasWheel}
|
||||
></canvas>
|
||||
|
||||
{/* FLOATING ZOOM CONTROLS */}
|
||||
|
||||
Reference in New Issue
Block a user