Skip to content

Commit 6431d99

Browse files
committed
Added ability to set dragStart, drag and dragEnd callbacks.
1 parent 386e5f6 commit 6431d99

6 files changed

Lines changed: 31 additions & 2 deletions

File tree

v3/src/input/InteractiveObject.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
5252
// gameObject, pointer, x, y
5353
onMove: NOOP,
5454

55+
// gameObject, pointer, x, y
5556
onDragStart: NOOP,
57+
58+
// gameObject, pointer, x, y
5659
onDrag: NOOP,
60+
61+
// gameObject, pointer, x, y
5762
onDragEnd: NOOP
5863

5964
};

v3/src/input/local/SceneInputManager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ var SceneInputManager = new Class({
107107
setOnOverCallback: require('./inc/SetOnOverCallback'),
108108
setOnUpCallback: require('./inc/SetOnUpCallback'),
109109
setOnMoveCallback: require('./inc/SetOnMoveCallback'),
110+
setOnDragStartCallback: require('./inc/SetOnDragStartCallback'),
111+
setOnDragCallback: require('./inc/SetOnDragCallback'),
112+
setOnDragEndCallback: require('./inc/SetOnDragEndCallback'),
110113

111114
processOverOutEvents: require('./inc/ProcessOverOutEvents'),
112115
processDownEvents: require('./inc/ProcessDownEvents'),

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,12 @@ var ProcessDragEvents = function (pointer, time)
203203
this.events.dispatch(new InputEvent.DRAG_ENTER(pointer, gameObject, input.target));
204204
}
205205

206-
this.events.dispatch(new InputEvent.DRAG(pointer, gameObject));
206+
var dragEvent = new InputEvent.DRAG(pointer, gameObject);
207207

208-
input.onDrag(gameObject, pointer);
208+
this.events.dispatch(dragEvent);
209+
210+
// Maybe it would be better to send the event to the callback? So you can get all the other stuff from it?
211+
input.onDrag(gameObject, pointer, dragEvent.dragX, dragEvent.dragY);
209212
}
210213
}
211214

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var SetOnDragCallback = function (gameObjects, callback, context)
2+
{
3+
return this.setCallback(gameObjects, 'onDrag', callback, context);
4+
};
5+
6+
module.exports = SetOnDragCallback;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var SetOnDragEndCallback = function (gameObjects, callback, context)
2+
{
3+
return this.setCallback(gameObjects, 'onDragEnd', callback, context);
4+
};
5+
6+
module.exports = SetOnDragEndCallback;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var SetOnDragStartCallback = function (gameObjects, callback, context)
2+
{
3+
return this.setCallback(gameObjects, 'onDragStart', callback, context);
4+
};
5+
6+
module.exports = SetOnDragStartCallback;

0 commit comments

Comments
 (0)