davidfig/pixi-viewport

Defining custom zoom bar.

blnvdanil opened this issue · 3 comments

Hello! Is there any way to define a custom zoom bar? I'd like to be able to define a constant, for instance [0.1, 50, 100], this array contains all possible zoom values. So when user will use wheel, I will determine what is the next value of zoom.

I came up with the only one way -- just reassign the value of Wheel#wheel() method with my own implementation of zooming, but I do not find it very convenient, and I feel that I miss something.

Thanks!

Not sure I follow. Do you want to add a menu that has different zoom percentages? That's relatively easy. You would create the UI and then tie it into viewport.setZoom (or whichever zoom function you'd like to use). Not sure why you would change the wheel plugin.

Lets imagine I have [1, 25, 50, 100] (only that values of zoom are possible) zoom values (in percentages), and current zoom is 25 percent, when wheel event happens, I want to change zoom to either 1 or 50.

I just want to get rid of zoom values like 1.9993939939 and so on.

Ah. Yes, you'd have to rewrite the wheel plugin with your array as the only valid options. It should be pretty straightforward.