diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e1329759..5db497351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ * The Particle tint value was incorrectly calculated, causing the color channels to be inversed. Fix #3643 (thanks @rgk) * 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) * Camera.cull will now accurately return only the Game Objects in the camera's view, instead of them all. Fix #3646 (thanks @KingCosmic @Yora) +* The `dragend` event would be broadcast even if the drag distance or drag time thresholds were not met. Fix #3686 (thanks @RollinSafary) Changes the checks for Camera.cull to give only the game objects in the camera's view instead of all game objects diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 1a5c91e78..cdd521470 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -686,7 +686,7 @@ var InputPlugin = new Class({ } // 4 = Pointer actively dragging the draglist and has moved - if (pointer.dragState === 4 && pointer.justMoved) + if (pointer.dragState === 4 && pointer.justMoved && !pointer.justUp) { var dropZones = this._tempZones; @@ -779,32 +779,36 @@ var InputPlugin = new Class({ input = gameObject.input; - input.dragState = 0; - - input.dragX = input.localX - gameObject.displayOriginX; - input.dragY = input.localY - gameObject.displayOriginY; - - var dropped = false; - - if (input.target) + if (input.dragState === 2) { - gameObject.emit('drop', pointer, input.target); + input.dragState = 0; - this.emit('drop', pointer, gameObject, input.target); + input.dragX = input.localX - gameObject.displayOriginX; + input.dragY = input.localY - gameObject.displayOriginY; - input.target = null; + var dropped = false; - dropped = true; + if (input.target) + { + gameObject.emit('drop', pointer, input.target); + + this.emit('drop', pointer, gameObject, input.target); + + input.target = null; + + dropped = true; + } + + // And finally the dragend event + + gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); + + this.emit('dragend', pointer, gameObject, dropped); } - - // And finally the dragend event - - gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); - - this.emit('dragend', pointer, gameObject, dropped); } pointer.dragState = 0; + list.splice(0); }