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

Vue plugin - smooth scroll

0 votes
added Jun 13, 2018 in Vue by theoh_lee Corporal (810 points)
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'

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>

Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.