fix
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user