Skip to content

Commit 8aa116c

Browse files
committed
The dragend event would be broadcast even if the drag distance or drag time thresholds were not met. Fix phaserjs#3686
1 parent de8462e commit 8aa116c

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* The Particle tint value was incorrectly calculated, causing the color channels to be inversed. Fix #3643 (thanks @rgk)
3939
* All Game Objects that were in Containers were being destroyed twice when a Scene was shutdown. Although not required it still worked in most cases, except with TileSprites. TileSprites specifically have been hardened against this now but all Game Objects inside Containers now have a different event flow, stopping them from being destroyed twice (thanks @laptou)
4040
* Camera.cull will now accurately return only the Game Objects in the camera's view, instead of them all. Fix #3646 (thanks @KingCosmic @Yora)
41+
* The `dragend` event would be broadcast even if the drag distance or drag time thresholds were not met. Fix #3686 (thanks @RollinSafary)
4142

4243
Changes the checks for Camera.cull to give only the game objects in the camera's view instead of all game objects
4344

src/input/InputPlugin.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ var InputPlugin = new Class({
686686
}
687687

688688
// 4 = Pointer actively dragging the draglist and has moved
689-
if (pointer.dragState === 4 && pointer.justMoved)
689+
if (pointer.dragState === 4 && pointer.justMoved && !pointer.justUp)
690690
{
691691
var dropZones = this._tempZones;
692692

@@ -779,32 +779,36 @@ var InputPlugin = new Class({
779779

780780
input = gameObject.input;
781781

782-
input.dragState = 0;
782+
if (input.dragState === 2)
783+
{
784+
input.dragState = 0;
783785

784-
input.dragX = input.localX - gameObject.displayOriginX;
785-
input.dragY = input.localY - gameObject.displayOriginY;
786+
input.dragX = input.localX - gameObject.displayOriginX;
787+
input.dragY = input.localY - gameObject.displayOriginY;
786788

787-
var dropped = false;
789+
var dropped = false;
788790

789-
if (input.target)
790-
{
791-
gameObject.emit('drop', pointer, input.target);
791+
if (input.target)
792+
{
793+
gameObject.emit('drop', pointer, input.target);
792794

793-
this.emit('drop', pointer, gameObject, input.target);
795+
this.emit('drop', pointer, gameObject, input.target);
794796

795-
input.target = null;
797+
input.target = null;
796798

797-
dropped = true;
798-
}
799+
dropped = true;
800+
}
799801

800-
// And finally the dragend event
802+
// And finally the dragend event
801803

802-
gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped);
804+
gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped);
803805

804-
this.emit('dragend', pointer, gameObject, dropped);
806+
this.emit('dragend', pointer, gameObject, dropped);
807+
}
805808
}
806809

807810
pointer.dragState = 0;
811+
808812
list.splice(0);
809813
}
810814

0 commit comments

Comments
 (0)