pixi-viewport icon indicating copy to clipboard operation
pixi-viewport copied to clipboard

Any way to make clamp zoom based on a percentage?

Open gs11118 opened this issue 6 years ago • 1 comments

I can't wrap my mind how those minWidth and maxWidth actually works. Also now on small devices people can't zoom enough. I'm so confused why is done this way and why not a simple scale.x and I set the min and max scale.

I tried to clamp it myself but then the viewport starts moving when I reach the max...

Any suggestions?

gs11118 avatar Oct 13 '19 13:10 gs11118

yup. it's a bit confusing. min/max are calculated as the number of world pixels shown on the screen. so if you have a 100x100 world and set max to 100, it would clamp to the size of the world. if you set max to 200, it would clamp to twice the size of the world. to get percentage of world, just feed it the worldWidth * multiple

yes, i agree, adding an actual scale value instead of the min/max would be helpful. i don't have time right now to add it, however. i'm happy to accept a PR or i'll add it to my list. i would add minScaleX, maxScaleX, etc. and then use that or minWidth, etc. when defined.

davidfig avatar Oct 23 '19 05:10 davidfig