davidfig / pixi-scrollbox

a scrollbox built for pixi.js using a masked box that scrolls vertically and/or horizontally with optional scrollbars
https://www.npmjs.com/package/pixi-scrollbox
MIT License
171 stars 33 forks source link

Scrolling sideways using a mousewheel #51

Open IJsLauw opened 2 years ago

IJsLauw commented 2 years ago

How can I tell the scrollbar or rather the viewport to scroll on the x axis using the mousewheel?

From the api of viewport I thought this should have worked:

`scrollbox.content.wheel = false

scrollbox.content.drag( { direction: 'x', wheel: true })`

But it didn't, am I doing this all wrong? Can someone show me how to achieve this?

davidfig commented 2 years ago

I don't think there's support for that behavior in the code. After turning off the wheel listener in the pixi-scrollbox (or perhaps pixi-viewport?), you'll have to add your own wheel listener to support it. Just look for the wheel listener and then follow the code and you should find how we did the y scrolling.

IJsLauw commented 2 years ago

Ok, that sounds like that could work (too?), but what is above code supposed to do then?

image

Again looking at the above docs for pixi-viewport which (scrollbox.content is right?). To me it reads as I can use the wheel to drag in the direction supplied, if I disable the wheel plugin (for zooming)

davidfig commented 2 years ago

Yes, you can use drag just like it's used in pixi-scrollbox. But i don't think the drag plugin supports the wheel in the 'x' direction. You can check. If not, either create a new plugin for the scrollbox.content (viewport), or handle the wheel even in your client code.