Vue plugin - smooth scroll

0 votes
390 views
added Jun 13, 2018 in Vue by anonymous
edited Jul 13, 2018 by LC Marshal

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>
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...