Smooth scroll with vue2-smooth-scroll
Javascript insertion
npm install --save vue2-smooth-scroll //or
yard add
// import on your project (less then 1KB gziped) - main.js
import vueSmoothScroll from 'vue2-smooth-scroll'
Vue.use(vueSmoothScroll)
Default settings
{
duration: 500, // Animation speed
offset: 0, // Offset from element, you can use positive or negative values
cotainer: '', // the scroll container, default is window,use document.querySelector to query the Element
}
HTML insertion
<div id="container">
<a href="#div-id" v-smooth-scroll="{ duration: 1000, offset: -50, container: '#container' }">Anchor</a>
<div id="div-id"></div>
</div>