mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 06:30:38 +00:00
InputHandler.dragStopBlocksInputUp is a boolean that allows you to control what happens with the input events. If false
(the default) then both the onInputUp
and onDragStop
events will get dispatched when a Sprite stops being dragged. If true
then only the onDragStop
event is dispatched, and the onInputUp
is skipped.
This commit is contained in:
parent
913936f080
commit
1956d3584e
3 changed files with 12 additions and 1 deletions
|
@ -350,6 +350,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
* InputHandler.dragTimeThreshold gives you more fine control over when a Sprite Drag event will start. It allows you to specify a time, in ms that the pointer must have been held down for, before the drag will begin.
|
||||
* InputHandler.downPoint is a new Point object that contains the coordinates of the Pointer when it was first pressed down on the Sprite.
|
||||
* There are two new Phaser consts available, for help with orientation of games or Game Objects. They are `Phaser.HORIZONTAL`, `Phaser.VERTICAL`, `Phaser.LANDSCAPE` and `Phaser.PORTRAIT`.
|
||||
* InputHandler.dragStopBlocksInputUp is a boolean that allows you to control what happens with the input events. If `false` (the default) then both the `onInputUp` and `onDragStop` events will get dispatched when a Sprite stops being dragged. If `true` then only the `onDragStop` event is dispatched, and the `onInputUp` is skipped.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -181,6 +181,11 @@ Phaser.InputHandler = function (sprite) {
|
|||
*/
|
||||
this.dragFromCenter = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} dragStopBlocksInputUp - If enabled, when the Sprite stops being dragged, it will only dispatch the `onDragStop` event, and not the `onInputUp` event. If set to `false` it will dispatch both events.
|
||||
*/
|
||||
this.dragStopBlocksInputUp = false;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} dragStartPoint - The Point from which the most recent drag started from. Useful if you need to return an object to its starting position.
|
||||
*/
|
||||
|
@ -1117,7 +1122,11 @@ Phaser.InputHandler.prototype = {
|
|||
|
||||
if (this.sprite && this.sprite.events)
|
||||
{
|
||||
this.sprite.events.onInputUp$dispatch(this.sprite, pointer, isOver);
|
||||
if (!this.dragStopBlocksInputUp ||
|
||||
this.dragStopBlocksInputUp && !(this.draggable && this.isDragged && this._draggedPointerID === pointer.id))
|
||||
{
|
||||
this.sprite.events.onInputUp$dispatch(this.sprite, pointer, isOver);
|
||||
}
|
||||
|
||||
// The onInputUp event may have changed the sprite so that checkPointerOver is no longer true, so update it.
|
||||
if (isOver)
|
||||
|
|
1
typescript/phaser.d.ts
vendored
1
typescript/phaser.d.ts
vendored
|
@ -1960,6 +1960,7 @@ declare module "phaser" {
|
|||
dragFromCenter: boolean;
|
||||
draggable: boolean;
|
||||
dragStartPoint: Phaser.Point;
|
||||
dragStopBlocksInputUp: boolean;
|
||||
dragTimeThreshold: number;
|
||||
enabled: boolean;
|
||||
game: Phaser.Game;
|
||||
|
|
Loading…
Reference in a new issue