Skip to content

No mouse interactions work with negative scaling #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matkovski opened this issue Oct 31, 2024 · 1 comment
Open

No mouse interactions work with negative scaling #500

matkovski opened this issue Oct 31, 2024 · 1 comment

Comments

@matkovski
Copy link

I need to have the Y axis point upwards, and the only sensible way I found to do this is just to set negative scale to it.

viewport.scale = new Point(1, -1);

Apparently this needs to be done to viewport and not the app stage. This effectively rotates everything around the X axis, and my coordinate system is what I wanted. What is happening now though is that zooming, panning and all other mouse interactions stop working - I'm not getting any exceptions, there's simply no reaction to any mouse movements.

@matkovski
Copy link
Author

matkovski commented Oct 31, 2024

With some debugging I managed to figure out what the problem is. Or problems, for that matter.

First, panning doesn't work because the hitArea of the viewport is, at this scale, a rectangle with negative height, and the contains() method of the Rectangle class instantly returns false when checking for hits, and the event is not handled. Rectangles probably would need to readjust themselves to make sure this doesn't happen. Or handle negative values, why not. Or created provided correct positive dimensions - I suppose this is the option here since the Rectangle class is part of pixijs, not pixi-viewport.

Second, mouse wheel and touch events don't work because in the InputManager.ts, line 237, there's a hardcoded assumption that the Y axis points down (y > top and y < bottom). I would assume this check should be simply if (viewport.hitArea.contains(point.x, point.y)), provided the issue above is fixed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant