Direct all scrolling to the x-axis
See original GitHub issueNot an issue, just a question. 😃
Version 8.0.0
Great library!
What i’m trying to do: I have a horizontal scrolling container. I want to direct all scrolling to the x-axis. So if you use the scroll wheel ( up - down ) it will scroll left-right. Also when you scroll left-right ( trackpad etc ) it will use default scroll left-right.
The start would be to use the “invertDelta” plugin to convert the axis. This already works great, when im scrolling up and down it scrolls the container left to right. But how to I combine this with the normal left to right behaviour?
Like this example: buildinamsterdam.com
The only way I thought of to get it to work ( solution could be very wrong ) is to check if if the direction is horizontal / verical in the invertDeltaPlugin:
if (delta.x !== 0) { console.log("horizontal"); } else { console.log("vertical"); }
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
An important point is that we are likely to get both
deltaX
anddeltaY
while using trackpads (even you don’t intend to), soy = 0
barely happens.Personally, I prefer using the norm of vector
(x, y)
(as commented above).Edit: the first solution behaves better in the demo 🙃 https://codepen.io/idiotWu/pen/KJNYye?editors=0010
I think this should be implemented as a plugin or a feature. it has a lot of use-cases