cancel the dragging event if the pointer is outside stage

This commit is contained in:
Yueyu 2021-07-06 06:39:28 +08:00
parent a7d7cb1763
commit 5fc7775748

View file

@ -472,6 +472,12 @@ export default class Stage {
return; return;
} }
var pt = this.getStagePt(e); var pt = this.getStagePt(e);
// if pointer is outside stage
// cancel the dragging event
if (pt.x < 0 || pt.x > this.width || pt.y < 0 || pt.y > this.height) {
Events.dragged = false;
return;
}
var delta = Vector.diff(pt, this.initialPoint); var delta = Vector.diff(pt, this.initialPoint);
var dist = ScratchJr.inFullscreen ? 15 : 5; var dist = ScratchJr.inFullscreen ? 15 : 5;
if (!Events.dragged && (Vector.len(delta) > dist)) { if (!Events.dragged && (Vector.len(delta) > dist)) {