Skip to content

Commit c5cfae0

Browse files
committed
Fix drag coordinates with camera zoom (issue 4755)
The dragX and dragY passed to 'dragStart' and 'drag' events are supported to be in world coordinates (as specified by the docs) but the coordinates used (pointer.x and pointer.y) were not transformed by the camera into world space. The drags now use pointer.worldX and pointer.worldY which are the post-transform coordinates.
1 parent 000beb2 commit c5cfae0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/input/InputPlugin.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,8 @@ var InputPlugin = new Class({
11261126
input.dragStartX = gameObject.x;
11271127
input.dragStartY = gameObject.y;
11281128

1129-
input.dragStartXGlobal = pointer.x;
1130-
input.dragStartYGlobal = pointer.y;
1129+
input.dragStartXGlobal = pointer.worldX;
1130+
input.dragStartYGlobal = pointer.worldY;
11311131

11321132
input.dragX = input.dragStartXGlobal - input.dragStartX;
11331133
input.dragY = input.dragStartYGlobal - input.dragStartY;
@@ -1330,13 +1330,13 @@ var InputPlugin = new Class({
13301330

13311331
if (!gameObject.parentContainer)
13321332
{
1333-
dragX = pointer.x - input.dragX;
1334-
dragY = pointer.y - input.dragY;
1333+
dragX = pointer.worldX - input.dragX;
1334+
dragY = pointer.worldY - input.dragY;
13351335
}
13361336
else
13371337
{
1338-
var dx = pointer.x - input.dragStartXGlobal;
1339-
var dy = pointer.y - input.dragStartYGlobal;
1338+
var dx = pointer.worldX - input.dragStartXGlobal;
1339+
var dy = pointer.worldY - input.dragStartYGlobal;
13401340

13411341
var rotation = gameObject.getParentRotation();
13421342

0 commit comments

Comments
 (0)