React-custom-scrollbars: Horizontal scrolling with wheel

Created on 2 Feb 2017  路  4Comments  路  Source: malte-wessel/react-custom-scrollbars

Using a mouse wheel works only on vertical scrolling. When scroll list is horizontal, scrolling works only by dragging and clicking the bar.

Most helpful comment

I use

onMouseWheel(e) {
    const currentScrollDelta = this.scrollBars.getScrollLeft();
    this.scrollBars.scrollLeft(currentScrollDelta + e.deltaY);
}

All 4 comments

I'm looking for something exactly like you described. Did you found a workaround for this?

Yes, you can bind regular onWheel event to your scrollbar and then use it like this:

_onMouseWheel: function(event) { if (this.props.direction === 'horizontal') { var list = event.currentTarget.firstChild; var delta = (event.deltaX == 0 ? event.deltaY : event.deltaX); list.scrollLeft += delta; event.preventDefault(); } },
Normally you use deltaY, and deltaX check is for mac trackpad.

I am using this: https://www.npmjs.com/package/normalize-wheel for fixing cross-browser issues.

I use

onMouseWheel(e) {
    const currentScrollDelta = this.scrollBars.getScrollLeft();
    this.scrollBars.scrollLeft(currentScrollDelta + e.deltaY);
}

I use

onMouseWheel(e) {
  const currentScrollDelta = this.scrollBars.getScrollLeft();
  this.scrollBars.scrollLeft(currentScrollDelta + e.deltaY);
}

awesome solve my problem :) thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

umer4ik picture umer4ik  路  4Comments

luxotus picture luxotus  路  4Comments

magnetronnie picture magnetronnie  路  3Comments

eyal1990 picture eyal1990  路  5Comments

Niryo picture Niryo  路  3Comments