@zippytech/react-scroll-container
v2.0.15
Published
Custom scrollbars for your React components
Downloads
22
Maintainers
Readme
react-scroll-container-pro
Custom scrollbars for your React components
Install
$ npm i --save @zippytech/react-scroll-container-pro
Usage
Just import the ScrollContainer code and styles into your app and you're ready to go!
import ScrollContainer from '@zippytech/react-scroll-container-pro'
import '@zippytech/react-scroll-container-pro/index.css'
<ScrollContainer>
SCROLLABLE CONTENT HERE ...
Lorem cupidatat ut elit magna culpa cupidatat velit id.
</ScrollContainer>
Props
alwaysShowTrack
: Boolean - defaults tofalse
. Iftrue
, the scroll track is always shown when the scrollthumb is visible.autoHide
: Boolean - defaults totrue
. Iftrue
, scrollbars are hidden when not scrolling.dragToScroll
: Boolean - defaults totrue
. Iffalse
, the scrollbars cannot be dragged with the mouse cursor.emptyScrollOffset
: Number - defaults to100
. The offset to use to hide the native scrollbars. In some special cases, you might want to set it to0
.hideDelay
: Number - defaults to 400 (in ms). The delay to wait in order to hide the scrollbarshideTransitionDuration
: String - defaults to300ms
. The duration of the transition effect used when hiding the scrollbars.inlineBlock
: Boolean - defaults tofalse
. Iftrue
, the scroll container will render adiv
withdisplay: inline-block
.scrollStopDelay
: Number - defaults to100
. The duration to wait after the last scroll event in order to triggeronScrollStop
.scrollThumbMargin
: Number - defaults to2
showDelay
: Number - defaults to 100 (in ms). The delay to wait in order to show the scrollbarsshowTransitionDuration
: String - defaults to100ms
. The duration of the transition effect used when showing the scrollbars.showTrackOnDrag
: Boolean - defaults tofalse
. Iftrue
, the scrollbar track will always be visible when the scroll thumb is dragged, even if the mouse cursor is not over it.rafOnScroll
: Boolean - defaults totrue
. Iftrue
, will do the onScroll logic on raf, otherwise immediately.scrollbars
: Boolean|Object({vertical, horizontal}) - By default, both scrollbars are displayed when needed. You can use this prop in order to hide one or both scrollbars (scrolling can still happen). Ifscrollbars === false
, the scrollbars are no longer displayed. If an object, it can havehorizontal
and/orvertical
keys. If one of them is=== false
, that respective scrollbar is no longer displayedtabName
: String - a tagName to use instead of the defaultdiv
scrollThumbMargin
: Number - defaults to2
. For the vertical scrollbar, this is the distance between the right edge of the scrollbar margin to the right edge of the scroll container. For the horizontal scrollbar, this is the distance between the bottom edge of the scrollbar margin to the bottom edge of the scroll container.scrollThumbStartEndRespectMargin
: Boolean - defaults tofalse
. If true, thescrollThumbMargin
will also be applied to the start/end of the scrollthumb. So, for the vertical scrollbar,scrollThumbMargin
will also be applied to top/bottom, and for the horizontal scrollbar,scrollThumbMargin
will also be applied to left/right edges.scrollThumbWidth
: Number - defaults to7
- the dimension of the scroll thumbscrollThumbOverWidth
: Number - defaults to10
- the dimension of the scroll thumb on mouse over (is also the dimension of the scroll track)scrollThumbRadius
: Number - defaults toscrollThumbWidth
scrollThumbStyle
: ObjectscrollerStyle
: ObjectviewClassName
: StringviewStyle
: ObjectavoidRepaintOnScroll
: Boolean - defaults to true. Will try to avoid repainting while scrolling, by addingbackface-visibility: hidden
;showScrollbarsOnOver
: Boolean - defaults to true. Will show the scrollbars when the mouse gets over the scroll container and hide on mouseout.
Callback props
onContainerScroll
:Function({ scrollTop, scrollLeft })
- called when the scroll container has been scrolled, either vertically or horizontallyonContainerScrollHorizontal
:Function(scrollLeft)
- only called when the scroll container has been scrolled horizontallyonContainerScrollHorizontalMin
:Function(scrollLeft)
- only called when the scroll container has been scrolled horizontally, and it has reached the minimum scrollLeft value (ie, 0)onContainerScrollHorizontalMax
:Function(scrollLeft)
- only called when the scroll container has been scrolled horizontally, and it has reached the maximum scrollLeft valueonContainerScrollVertical
:Function(scrollTop)
- only called when the scroll container has been scrolled verticallyonContainerScrollVerticalMin
:Function(scrollTop)
- only called when the scroll container has been scrolled vertically, and it has reached the minimum scrollTop value (ie, 0)onContainerScrollVerticalMax
:Function(scrollTop)
- only called when the scroll container has been scrolled vertically, and it has reached the maximum scrollTop valueonResize
:Function({ width, height })
onScrollbarsChange
:Function({ horizontal: Boolean, vertical: Boolean })
- called when scrollbar visibility has changed - that is, a scrollbar has been shown or hiddenonScrollbarStartDrag
:Function(orientation: String("horizontal"|"vertical")
- called when the user starts dragging one of the scrollbars with the mouse cursoronHorizontalScrollbarStartDrag
: Function - equivalent toonScrollbarStartDrag("horizontal")
onVerticalScrollbarStartDrag
: Function - equivalent toonScrollbarStartDrag("vertical")
onScrollbarStopDrag
:Function(orientation: String("horizontal"|"vertical")
- called when the user releases one of the scrollbars after dragging it with the mouse cursoronHorizontalScrollbarStopDrag
: Function - equivalent toonScrollbarStopDrag("horizontal")
onVerticalScrollbarStopDrag
: Function - equivalent toonScrollbarStopDrag("vertical")
onScrollStart
:Function({ scrollTop, scrollLeft })
- called when scrolling starts (it can start either via scrollbar drag, mouse wheel or via keyboard interaction)onScrollStop
:Function({ scrollTop, scrollLeft })
- called when scrolling stops - also seescrollStopDelay
onViewResize
:Function({ width, height })
- called when the scroll container content changes size
Public API methods
Named exports
- cleanProps(props, propTypes)
- propTypes - the propTypes of
ScrollContainer