mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-02-17 17:01:12 -05:00
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:
commit
0cbbc48769
1 changed files with 14 additions and 0 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue