ScrollSpy in pure JavaScript
npm install vanillajs-scrollspyScrollSpy in pure JavaScript.
``bash`
$ npm install vanillajs-scrollspy --save
- menu: HTML selector (#id, .class, ...)
- speed (optional): scroll speed, default value 2000'easeOutSine'
- easing (optional): scroll type , 'easeInOutSine' or 'easeInOutQuint', default value 'easeOutSine'
`javascript
import VanillaScrollspy from 'vanillajs-scrollspy'
const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu })
scrollspy.init()
`
`html`
After that the library will be available to the Global as VanillaScrollspy. Follow an example:
` javascript`
const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu })
scrollspy.init()
Available in public/index.html.
` html
Home
Portfolio
About
Contact
`
` javascript`
const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu, speed: 1000 })
scrollspy.init()
` javascript``
const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu, speed: 1000, easing: 'easeInOutQuint' })
scrollspy.init()
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details