fix: avoid passive wheel preventDefault warnings in canvas
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-02-20 09:28:31 +08:00
parent 056514f167
commit 1cf7f2c1f1

View File

@ -85,7 +85,9 @@ export function CanvasWorkspace() {
if (!container) return;
const preventTrackpadHistorySwipe = (event: WheelEvent) => {
event.preventDefault();
if (event.cancelable) {
event.preventDefault();
}
};
container.addEventListener("wheel", preventTrackpadHistorySwipe, { passive: false });
@ -312,7 +314,9 @@ export function CanvasWorkspace() {
// 处理滚轮缩放
const handleWheel = useCallback((e: React.WheelEvent) => {
if (!isEventFromCanvasContainer(e.target)) return;
e.preventDefault();
if (e.cancelable) {
e.preventDefault();
}
e.stopPropagation();
// mac: 双指滚动默认平移,Cmd/Ctrl+滚轮才缩放(保留触控板体验)