malte-wessel / react-custom-scrollbars

React scrollbars component
http://malte-wessel.github.io/react-custom-scrollbars/
MIT License
3.2k stars 578 forks source link

How to disable the horizontal scrollbar? #213

Open navinprasadk opened 6 years ago

ryan-ds17 commented 6 years ago

Add this to the scrollbar props
renderTrackHorizontal={props => <div {...props} style={{display: 'none'}} className="track-horizontal"/>}

slim1801 commented 6 years ago

@ryan-ds17 I believe this just hides the scrollbar but still enables scrolling for that direction. Is there a way to just totally ignore horizontal or vertical scrolling?

Would be nice if there was a prop like disableHorizontalScrolling and disableVerticalScrolling

bruno-de-queiroz commented 6 years ago

usually if the horizontal bar is appearing is because the inner content wrapper does not have overflow: hidden. Try that to see if solves

pawelangelow commented 5 years ago

In addition to @creativelikeadog 's answer ->

renderView={props => (
    <div {...props} style={{ ...props.style, overflowX: 'hidden' }} />
)}

I had to set overflow-x of the content wrapper to hidden.

Losses commented 4 years ago

@pawelangelow If there's a autoHeight flag, the height of renderView need to be handled seperately.

@malte-wessel What about providing a separate flag for this feature?

ex-rajesh-edx commented 3 years ago

Add this css code -

/* disable horizontal scroll */
.credential-scroll div {
  overflow-x: hidden !important;
}
Attila217 commented 2 years ago

i use this trick:

const ref = useRef(); const someRef = useRef({ scrollLeft: 0, scrollTop: 0, }); const handleOnScrollFrame = useCallback(event => { if (disabled) { ref.current.scrollLeft(someRef.current.scrollLeft); ref.current.scrollTop(someRef.current.scrollTop); } else { someRef.current.scrollLeft = event.scrollLeft; someRef.current.scrollTop = event.scrollTop; } }, [disabled])

<Scrollbars onScrollFrame={handleOnScrollFrame} ref={ref} {...props}

{children}

mdodge-ecgrow commented 1 year ago

In addition to @creativelikeadog 's answer ->

renderView={props => (
    <div {...props} style={{ ...props.style, overflowX: 'hidden' }} />
)}

I had to set overflow-x of the content wrapper to hidden.

That code works great in Firefox. But for my application it actually broke it in Chrome. In Chrome, part of the bottom got chopped off or hidden, I am assuming the height of the scrollbar.