This commit is contained in:
2025-10-15 15:28:21 +08:00
parent 3bcbbd26e8
commit 0d94f895a3
9 changed files with 80 additions and 50 deletions
@@ -9,6 +9,7 @@ import {
view,
Size,
Vec3,
EventTouch,
} from "cc";
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
@@ -65,6 +66,12 @@ export class ShowPanel extends li_BaseView {
this
);
}
// 阻止触摸事件传递,防止拖动画面(特别是Web平台视频超出屏幕时)
this.node.on(Node.EventType.TOUCH_START, this.onTouchBlock, this);
this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchBlock, this);
this.node.on(Node.EventType.TOUCH_END, this.onTouchBlock, this);
this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchBlock, this);
}
onDestroy() {
@@ -76,6 +83,22 @@ export class ShowPanel extends li_BaseView {
this
);
}
// 清理触摸事件监听
this.node.off(Node.EventType.TOUCH_START, this.onTouchBlock, this);
this.node.off(Node.EventType.TOUCH_MOVE, this.onTouchBlock, this);
this.node.off(Node.EventType.TOUCH_END, this.onTouchBlock, this);
this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchBlock, this);
}
/**
* 阻止触摸事件传递,防止拖动画面
*/
private onTouchBlock(event: EventTouch) {
// 阻止事件冒泡
event.propagationStopped = true;
// 阻止浏览器默认行为(如拖动、滚动)
event.preventDefault();
}
protected onClose() {