Skip to content

yinjs/vue-scroll

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-scroll

scroll directive for vuejs 2.0

For vue 1.x, please use vue-scroll@1.0.4. Currently its code is in master branch.

NPM

Coveralls

npm package NPM downloads Average time to resolve an issue

Installation

NPM(recommended)

npm install vue-scroll --save

Standalone

Simple download from releases and include it in script tag.

Usage

Import

If you have an installed vue-scroll at your node_modules, you can import it like following(ES2015).

import vuescroll from 'vue-scroll'

Vue.use(vuescroll)

Make it work

It's very simple, just declar in html tags(Just like other standard vue directives) and provide a defined callback - the scroll function below.

In html:

<div v-scroll="onScroll">
...
</div>

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

Samples

LICENSE

MIT

About

Scroll directive on vue

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%