Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

Vue plugin - smooth scroll

0 votes
11 views
added Jun 13 in Vue by theoh_lee Corporal (810 points)
edited Jul 13 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>

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...