0.2.2 • Published 6 years ago

react-spy-scroll v0.2.2

Weekly downloads
15
License
X11
Repository
github
Last release
6 years ago

react-spy-scroll

Scrollspy components for react

circleci.com codecov.io Dependency Status devDependency Status peerDependency Status

How to install

npm install react-spy-scroll --save

How to use it

TODO

The most basic setup

TODO

The default behaviour

The library introduces four components; AnchorLink, AnchorButton, AnchorElement and ScrollPanel. The link and button are simple a and button tags wrapped in the Anchor component for ease of use.

To get startet you only need some AnchorXXXXs and AnchorElements with matching href and id props. If you want a scrolling area within your page, e.g. not a page-scroll, you can wrap your AnhorElements in a ScrollPanel.

AnchorElements have useful defaults by them self, but will inherit configuration from its parent ScrollPanel if one exists. If by change a AnchorElement defines a props which is also present at its parent ScrollPanel then the AnchorElements config will be used.

Anchor

PropNamePropTypeDefaultDescription
hrefPT.string.isRequiredNoneReference to AnchorElement's id
onClickPT.funcNoneonClick handler
activeClassPT.stringscroll-spy-activeThe class given to an Anchor when its AnchorElement is active

AnchorElement

PropNamePropTypeDefaultDescription
idPT.string.isRequiredNoneAn elements id
offsetPT.numberNoneScroll offset
childrenPT.element.isRequiredNoneReact children
isInsidePT.funcSee belowChecking if element is in view
isInside: (scrollOffset, elemTopBound, elemBottomBound) =>
        (scrollOffset >= elemTopBound && scrollOffset <= elemBottomBound)

ScrollPanel

PropNamePropTypeDefaultDescription
offsetPT.number0Scroll offset
eventsPT.object{}Callbacks for start/end of scroll
animatePT.booltrueAnimated scroll
tagPT.stringdivDOM-tag
classNamePT.stringscroll-panelClassname
childrenPT.arrayOf(PT.element)NoneReact-children

Peer dependencies

This component has the newest react and react-router as peerdependenies, but will most likely work with lower version. If you test the component with lower versions of react and/or react-router please let me know so that the dependencies can be adjusted.

"react": "^0.14.7 || ^15.0.1"
"react-dom": "^0.14.7 || ^15.0.1"
0.2.2

6 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago