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

Vue plugin - smooth scroll

0 votes
3 views
added 6 days ago in Vue by theoh_lee Corporal (810 points)

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 based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.
...