vue-scroll
scroll directive for vuejs
Installation
NPM(recommended)
npm install vue-scroll --save-dev
You need to load it manually.
const Vue = require('vue')
const vScroll = require('vue-scroll')
Vue.use(vScroll)
Standlone
Simple download and include it in script tag. And it will be auto loaded into vue.
Usage
It's very simple, just declar in html tags and provide a defined callback - the scroll function below.
In javasript:
new Vue({
el: '#app',
data: {},
methods:{
onScroll:function(e, position){
this.position = position;
}
}
})
The function onScroll has two arguments, e is the scroll event object, position is an object which has two properties about the postion of scroll bar:
- scrollTop type:number
- scrollLeft type:number
In html:
<body v-scroll="onScroll">
...
</body>
Plain sample
LICENSE
MIT