0.6.7 • Published 3 years ago

react-scroll-component v0.6.7

Weekly downloads
68
License
MIT
Repository
github
Last release
3 years ago

React scroll component

npm NPM npm Libraries.io dependency status for GitHub repo

StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

React version

>= React 16.3

Install

yarn add react-scroll-component
npm install react-scroll-component

Import

import Scroll from 'react-scroll-component';
import {Scroll} from 'react-scroll-component';

Use

Create config object

PropertyTypeRequiredUsageDefault
classNamestring-Class is added to the wrapper element-
containerClassstring-Add class to the inner container that will wrap your content. Be careful when adding css properties. You might break the scroller here.-
containerReffunction-Use it to get a reference to the scrolling container. You can set scrollTop for vertical or scrollLeft for horizontal from the parent component. Don't forget to clear this reference.-
dimensionChangeTimeoutnumber-Call the handler for dimension change (height, width, maxHeight, maxWidth) with a timeout in milliseconds-
directionstringtrueChoose between vertical or horizontal scroll.-
displaystring--inline-block
height or widthstringtrueSet height for vertical scroll. Set width for horizontal scroll.-
maxHeight or maxWidthstring-Set maxHeight for vertical scroll. Set maxWidth for horizontal scroll.none
initTimeoutnumber-In milliseconds. Needed to ensure correct rendering of the scroller in some browsers and/or devices.200
minScrollerSizenumber-Set a minimum scroller height in pixels for vertical scroll or width in pixels for horizontal scroll. If a value higher than the corresponding container's size (the scrolling 'window' offsetHeight for vertical or offsetWidth for horizontal) is set the value will be limited to this container's size.0
noInitTimeoutboolean-Switch to true to switch off the initial timeout and render the scroller right away in componentDidMount.false
observeboolean-Resize scroller on child and subtree changes using the MutationObserver API.true
observerTimeoutnumber-Call the mutation observer callback with timeout in milliseconds.-
onScrollerTogglefunction-Callback that will be called after scroller appears or disappears. An object with a boolean property isDisplayed will be provided as an argument to the callback.-
onTrackClickfunction-Called when the track is clicked. An object with the following properties is provided as argument: container and track are references to the DOM elements, direction (-1 for up and 1 for down), and event. If this prop is provided it prevents the default shifting-
resizeDebouncenumber-In milliseconds. This is used to optimize the calls to the resize event handler.400
scrollerobject-This object is used as a style property on the scroller element. Set the left' orrightproperty for averticalscroll to position the scroller to the left or to the right. Usetoporbottomto position the scroller in ahorizontalscroll case. Setwidthto define the scroller's width. Set any other validCSSproperty to style the scroller as long as you don't overrideposition,toporbottomforverticalandleftorrightforhorizontal` scroll. Add vendor prefixes if necessary. Use PascalCase for the vendor prefixed properties. | -
scrollerClassstring-Use in similar way as the scroller property-
scrollSizeDebouncenumber-If provided the scroller size will be calculated with timeout equal to the value (in milliseconds). Can be useful when the main dimension is dynamically changed with transition. Then this will recalculate the scroller size and display after transition is done.-
trackboolean-States if the track should be rendered. Defaults to falsefalse
trackClassstringif track is trueThe class that will be applied to the track element-
trackShiftnumberif track is true and onTrackClick is not providedThe number of pixels that the container should scroll after clicking on the track-

Wrap content and spread the config

<Scroll {...config}> content </Scroll>

Browser support

  • Chrome, Edge, Firefox, IE11, Safari on desktop and mobile.
0.6.7

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago