React Scrollchor
A React component for scroll to #hash links with smooth animations. Scrollchor is a mix of Scroll and Anchor, a joke name for a useful component.
See it in action:
- demo video
- example page and source code
hash
is the id
of a HTML tag on current page.
Installation
npm
Dependencies
- User should provide their own
React
package
Usage
Prop types
Reactive props
Update props
will re-render Scrollchor
element
Custom animation
Animated behavior can be customize:
default animation settings
This setting is equivalent to default jQuery.animate easing: swing
more Easing
functions
before
and after
Animate callbacks
Use this callbacks to trigger behaviours like, for example, update state, load async stuffs, etc.
Simulate click API
Scrollchor include a dedicate API for init animate scroll programmatically that works like normal click events using simulateClick()
When used programmatically some use-case don't need anchor tags
. On this cases use childrenless Scrollchor
Childrenless Scrollchor
This component will render null
and the user it's reponsible of store the component reference, Ex: childrenless
Ex: calling simulateClick()
on childrenless ref