Simple and lightweight size scroll library.
npm install plain-scroll
PlainScroll is simple to usage. If you are using a module bundler, insert the following code into your project.
import PlainScroll from 'plain-scroll';
Please use plain-scroll.min.js when using with script tag.
<script src="plain-scroll.min.js"></script>
Next, create a instance.
new PlainScroll();
// or set option
new PlainScroll({
trigger: '.plain-scroll',
duration: 1000,
easing: 'easeOut'
onScrollStart: () => console.log('start'),
onScrollEnd: () => console.log('end')
});
Finally, attach the trigger name to anchor tag, prepare the element you want to scroll.
<a href="#to" class="plain-scroll">
<div id="to"></div>
You can set options at the same time you create an instance.
Class name for starting scrolling, set to anchor tag. Default set is '.plain-scroll'.
It is time to scroll to the destination. Default set is 1000 milliseconds.
Add inertia to the scroll. You can set either for 'linear', 'easeIn', 'easeOut', 'easeInOut'. Default set is 'easeOut'.
You can run any function at start and end of scroll.
Support for stable version in the modern browsers and Internet Explorer 11.
- Chrome
- Firefox
- Safari
- Edge
- Internet Explorer 11
MIT @darumock