Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
v-smooth-scroll
Advanced tools
Lightweight Vue plugin for smooth-scrolling.
For simple use-cases, the native scroll-behavior
CSS property (working draft) may be enough.
Compatible with Vue 3.x and Vue 2.x
requestAnimationFrame
(with fallback)npm install --save v-smooth-scroll
import VueSmoothScroll from 'v-smooth-scroll'
// Vue 2.x
Vue.use(VueSmoothScroll)
// Vue 3.x
const app = Vue.createApp({ /* options */ })
app.use(VueSmoothScroll)
app.mount('#app')
<a href="#sec-3" v-smooth-scroll>Section 3</a>
<section id="sec-3"></section>
const myEl = this.$refs.myEl || this.$el || document.getElementById(...)
this.$smoothScroll({
scrollTo: myEl,
hash: '#sampleHash' // required if updateHistory is true
})
<script>
<body>
<div id="app">
<a href="#bottom" v-smooth-scroll>Let's go to #bottom!</a>
<div style="height: 2000px;"></div>
<span id="bottom">bottom</span>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/v-smooth-scroll"></script>
<script>
Vue.use(windodw.VueSmoothScroll)
var app = new Vue({
el: '#app'
})
</script>
</body>
<body>
<div id="app">
<a href="#bottom" v-smooth-scroll>Let's go to #bottom!</a>
<div style="height: 2000px;"></div>
<span id="bottom">bottom</span>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/v-smooth-scroll"></script>
<script>
var app = Vue.createApp({ /* options */ })
app.use(windodw.VueSmoothScroll)
app.mount('#app')
</script>
</body>
{
duration: 500, // animation duration in ms
offset: 0, // offset in px from scroll element, can be positive or negative
container: '', // selector string or Element for scroll container, default is window
updateHistory: true // whether to push hash to history
easingFunction: null // gives the ability to provide a custom easing function `t => ...`
// (see https://gist.github.com/gre/1650294 for examples)
// if nothing is given, it will defaults to `easeInOutCubic`
}
import VueSmoothScroll from 'v-smooth-scroll'
// Vue 2.x
Vue.use(VueSmoothScroll, {
duration: 400,
updateHistory: false,
})
// Vue 3.x
vueApp.use(VueSmoothScroll, {
duration: 400,
updateHistory: false,
})
<div id="container">
<a href="#div-id" v-smooth-scroll="{ duration: 1000, offset: -50, container: '#container' }">Anchor</a>
<div id="div-id"></div>
</div>
this.$smoothScroll({
scrollTo: this.$refs.myEl,
duration: 1000,
offset: -50,
})
Thanks goes to these wonderful people (emoji key):
James 💻 | a-kriya 💻 🐛 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Simple vue smooth scroll
We found that v-smooth-scroll demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.