A vanilla smooth-scrolling JavaScript plugin with no dependencies.
- Blazing fast. (Using scrollIntoView)
- Lightweight.
- No dependencies.
Example page on CodePen.
# Using npm
npm install @marlospomin/smoothie
# Using yarn
yarn add @marlospomin/smoothie
Now include smoothie in your project and you should be good to go.
// es6
import smoothie from '@marlospomin/smoothie'
// commonjs
const smoothie = require('@marlospomin/smoothie')
Add data-smoothie
to your anchor tags and the target's id
in the href value as it follows below.
<a data-smoothie href="#example">...</a>
<!-- Somewhere below -->
<section id="example">
...
</section>
Call smoothie anywhere in your code:
// Call me
smoothie()
To configure the plugin just pass the desired option(s) as an object like the example below:
// Pass options like this
smoothie({
behavior: 'auto'
})
You can run tasks with the yarn
command like the example below:
# Build task
yarn build
# Lint task
yarn lint
You can check the browser support here.
If your desired browser is not in the list consider using this polyfill.
Contributing is really easy, just make a pull request or open an issue and we will go from there.
Code released under the MIT license.