Skip to content

Commit 829b1e7

Browse files
committed
Events.onDragUpdate has a new 6th property fromStart which is a boolean. You can determine if the event was the result of the start of a drag movement or not by polling it (phaserjs#2155)
1 parent 882c8b8 commit 829b1e7

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
307307
* EarCut now replaces PolyK, which fixes advanced Graphics mask triangulation issues such as #1941
308308
* Camera.checkBounds now takes the scale of the Camera into account (thanks @ForGorNorPor #2263)
309309
* InputHandler.consumePointerEvent has been removed, as it was never used internally anyway, so was misleading (thanks @GregoryAveryWeir #2227)
310+
* Events.onDragUpdate has a new 6th property `fromStart` which is a boolean. You can determine if the event was the result of the start of a drag movement or not by polling it (#2155)
310311

311312
### Bug Fixes
312313

src/input/InputHandler.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,14 +1036,19 @@ Phaser.InputHandler.prototype = {
10361036
* @param {Phaser.Pointer} pointer
10371037
* @return {boolean}
10381038
*/
1039-
updateDrag: function (pointer) {
1039+
updateDrag: function (pointer, fromStart) {
10401040

10411041
if (pointer.isUp)
10421042
{
10431043
this.stopDrag(pointer);
10441044
return false;
10451045
}
10461046

1047+
if (fromStart === undefined)
1048+
{
1049+
fromStart = false;
1050+
}
1051+
10471052
var px = this.globalToLocalX(pointer.x) + this._dragPoint.x + this.dragOffset.x;
10481053
var py = this.globalToLocalY(pointer.y) + this._dragPoint.y + this.dragOffset.y;
10491054

@@ -1106,7 +1111,7 @@ Phaser.InputHandler.prototype = {
11061111
}
11071112
}
11081113

1109-
this.sprite.events.onDragUpdate.dispatch(this.sprite, pointer, px, py, this.snapPoint);
1114+
this.sprite.events.onDragUpdate.dispatch(this.sprite, pointer, px, py, this.snapPoint, fromStart);
11101115

11111116
return true;
11121117

@@ -1330,7 +1335,7 @@ Phaser.InputHandler.prototype = {
13301335
this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(pointer.x), this.sprite.y - this.globalToLocalY(pointer.y));
13311336
}
13321337

1333-
this.updateDrag(pointer);
1338+
this.updateDrag(pointer, true);
13341339

13351340
if (this.bringToTop)
13361341
{

0 commit comments

Comments
 (0)