Skip to content

Commit d2f08f0

Browse files
committed
Added 'dropped' property to the DragEnd event.
1 parent a2d1f86 commit d2f08f0

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '5e2257c0-7301-11e7-9e81-8b040a356320'
2+
build: '980f6760-7325-11e7-a031-bfdaa3af0a4c'
33
};
44
module.exports = CHECKSUM;

v3/src/input/InteractiveObject.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
2525
// 2 = Being dragged
2626
dragState: 0,
2727

28+
dragStartX: 0,
29+
dragStartY: 0,
30+
2831
dragX: 0,
2932
dragY: 0,
3033

v3/src/input/local/components/ProcessDragEvents.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ var ProcessDragEvents = function (pointer, time)
112112
input = gameObject.input;
113113

114114
input.dragState = 2;
115+
115116
input.dragX = input.localX - gameObject.displayOriginX;
116117
input.dragY = input.localY - gameObject.displayOriginY;
117118

119+
input.dragStartX = gameObject.x;
120+
input.dragStartY = gameObject.y;
121+
118122
this.events.dispatch(new InputEvent.DRAG_START(pointer, gameObject));
119123

120124
input.onDragStart(gameObject, pointer, input.dragX, input.dragY);
@@ -218,23 +222,24 @@ var ProcessDragEvents = function (pointer, time)
218222
input = gameObject.input;
219223

220224
input.dragState = 0;
225+
221226
input.dragX = input.localX - gameObject.displayOriginX;
222227
input.dragY = input.localY - gameObject.displayOriginY;
223228

224-
// Any drop zones here?
225-
for (c = 0; c < currentlyOver.length; c++)
229+
var dropped = false;
230+
231+
if (input.target)
226232
{
227-
overGameObject = currentlyOver[c];
233+
this.events.dispatch(new InputEvent.DROP(pointer, gameObject, input.target));
228234

229-
if (overGameObject.input.dropZone)
230-
{
231-
this.events.dispatch(new InputEvent.DROP(pointer, gameObject, overGameObject));
232-
}
235+
input.target = null;
236+
237+
dropped = true;
233238
}
234239

235240
// And finally the dragend event
236241

237-
this.events.dispatch(new InputEvent.DRAG_END(pointer, gameObject));
242+
this.events.dispatch(new InputEvent.DRAG_END(pointer, gameObject, dropped));
238243

239244
input.onDragEnd(gameObject, pointer, input.dragX, input.dragY);
240245
}

v3/src/input/local/events/DragEndEvent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var DragEndEvent = new Class({
77

88
initialize:
99

10-
function DragEndEvent (pointer, gameObject)
10+
function DragEndEvent (pointer, gameObject, dropped)
1111
{
1212
Event.call(this, 'DRAG_END_EVENT');
1313

@@ -24,6 +24,9 @@ var DragEndEvent = new Class({
2424
this.x = pointer.x;
2525
this.y = pointer.y;
2626

27+
// When the drag ended did it fire a successful DROP event first?
28+
this.dropped = dropped;
29+
2730
this.dragX = gameObject.input.dragX;
2831
this.dragY = gameObject.input.dragY;
2932
}

0 commit comments

Comments
 (0)