Merge pull request #467 from yueyuzhao/issue/458-cancel-dragevent-outside-stage

cancel the dragging event if the pointer is outside stage
This commit is contained in:
chrisgarrity 2021-07-19 10:04:58 -04:00 committed by GitHub
commit 0cbbc48769
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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