- Install package
npm i @grafikri/vue-infinite-scroll
- Register it as vue plugin
Don't forget it register before create an Vue instance. here
import VueInfiniteScroll from "@grafikri/vue-infinite-scroll"
Vue.use(VueInfiniteScroll)
- Start to use it as directive in component
<template>
<div v-infinite-scroll="{ onEnter, onLeave, distance: 100 }">
This is my long content
</div>
</template>
<script>
export default {
name: "MyCustomComponent",
methods: {
onEnter() {
// do something
},
onLeave() {
// do something
},
},
}
</script>
The distance means space between view's and scroll's bottom positions. The value of distance is pixel.
Default: 200
Required:
false
The method when view's bottom appear.
Required:
true
on DOM
The method when view's bottom leave.
Required:
true
on DOM