Vue plugin - vue-scroll-to

0 votes
539 views
added Jun 14, 2018 in Vue by LC Marshal Captain (25,790 points)
npm install --save vue-scrollto //or
yarn add vue-scrollto
//As a vue directive (main.js)
var Vue = require('vue');
var VueScrollTo = require('vue-scrollto');
 
Vue.use(VueScrollTo)
 
// You can also pass in the default options
Vue.use(VueScrollTo, {
     container: "body",
     duration: 500,
     easing: "ease",
     offset: 0,
     cancelable: true,
     onStart: false,
     onDone: false,
     onCancel: false,
     x: false,
     y: true
 })
<!--Usage HTML-->
<a href="#" v-scroll-to="'#element'">Scroll to #element</a>
 
<div id="element">
    Hi. I'm #element.
</div>
<!--If you need to customize the scrolling options, you can pass in an object literal to the directive:-->
<a href="#" v-scroll-to="{
     el: '#element',
     container: '#container',
     duration: 500,
     easing: 'linear',
     offset: -200,
     cancelable: true
     onStart: onStart,
     onDone: onDone,
     onCancel: onCancel,
     x: false,
     y: true
 }">
    Scroll to #element
</a>
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...