Lock dragging to a single axis

Is “setDragLock” working in Phaser3? I am trying to implement single axis dragging like in match 3 games, I can’t find “setDragLock” in the documentation so i’m using

box.on('drag', function (pointer, dragX, dragY){
        if(dragX>dragY){this.x = dragX;}
        else {this.y = dragY;}
}

But this breaks as the object is dragged further away.

1 Like

Here is one way to do this:

this.input.setDraggable(box)
this.input.on('drag', function (pointer, gameObject, dragX, dragY) {
        gameObject.x = dragX;
});

This will only move the box on x axis.

1 Like

Does not work.
At least in my case.

P.S.
I’m using mouseSpring.