ilyashubin/scrollbooster

Horizontal scrolling with mouse wheel

strarsis opened this issue · 3 comments

@ilyashubin: Is it possible to use your library to allow horizontal scrolling by mouse wheel?
This is currently only possible with JavaScript as browsers don't seem to native have this behaviour.

Hello! Yeah, it is possible. If you scrolling with CSS only (transform property), you can use config like this:

new ScrollBooster({
    viewport,
    content,
    direction: 'horizontal',
    emulateScroll: true,
    onUpdate: (state) => {
        content.style.transform = `translateX(${-state.position.x}px)`
    }
})

If you use native scrolling, scrolling is handled by browser itself:

new ScrollBooster({
  viewport,
  content,
  direction: 'horizontal',
  onUpdate: (state) => {
    viewport.scrollLeft = state.position.x;
  }
})

@ilyashubin: Can I use with simplebar?

And is it possible to make the scroll content draggable with scrollbooster.

I think it is possible. Simplebar uses native browser scrolling, so there should not be problems. But I never tried, so cant say for sure
Let me know if they will work well together :)