https://github.com/Artrogeno/react-scrollspy-animate
Scrollspy Animate Component Demo
Install
$ yarn add react-scrollspy-animate
Usage
...
Properties
ScrollspypropTypes = tag: PropTypes componentClass: PropTypesstring scrolledPastClassName: PropTypesstring active: PropTypesstring level: PropTypesnumber offset: PropTypesnumber timeout: PropTypesnumber rootEl: PropTypesstring animete: PropTypesobject onUpdate: PropTypesfunc
Exemple
Default
Section 1 Section 2 Section 3
Level 1 ( tag --> a )
Section 1 Section 2 Section 3
Level 2 ... ( tag --> li > a )
<Scrollspy level={2} >
<li>
<a href="#section-1">Section 1</a>
</li>
<li>
<a href="#section-2">Section 2</a>
</li>
<li>
<a href="#section-3">Section 3</a>
</li>
</Scrollspy>
Active ( default ==> class="active" )
<Scrollspy active="nav-active" >
<li>
<a href="#section-1">Section 1</a>
</li>
<li class="nav-active"> <!--- Scroll Activite ---->
<a href="#section-2">Section 2</a>
</li>
<li>
<a href="#section-3">Section 3</a>
</li>
</Scrollspy>
Animate & Timeout from Mozilla (scrollIntoView)
// --> Animete
// <Scrollspy animate={ behavior: 'smooth', block: 'start' } >
{
behavior: "auto" | "instant" | "smooth",
block: "start" | "end",
}
// --> Set hash your browser in 500 milliseconds
// <Scrollspy timeout={500} >
setTimeout(() => {
window.location.hash = '#section-2'
}, timeout);