davidfig/pixi-viewport

Dragging in one direction at a time

Closed this issue · 4 comments

Hello! Is it possible to limit the viewport to dragging in the x-direction when pressing one button, and limit it to y-direction when holding a different button? Eventually just making it impossible to drag in both x and y direction at the same time by looking at the initial dragging direction and choosing x/y based on that? I want to be able to drag in both directions, just not at the same time.

The easiest way is to change the drag() plugin based on keypresses. In your keyboard listener, call viewport.drag({ direction: 'x' }) or 'y' based on the ky.

Ok, so it is okay to call the drag plugin multiple times?

Yes. Recalling a plugin replaces the old one.

Thanks!