forked from AkkomaGang/admin-fe
Fix on scroll event
This commit is contained in:
parent
7b4184cbde
commit
93866e78ae
1 changed files with 10 additions and 8 deletions
|
@ -31,16 +31,18 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('FetchReports')
|
||||
this.scroll(this.reports)
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('scroll', this.handleScroll)
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('scroll', this.handleScroll)
|
||||
},
|
||||
methods: {
|
||||
scroll(reports) {
|
||||
window.onscroll = () => {
|
||||
const bottomOfWindow = document.documentElement.scrollHeight - document.documentElement.scrollTop === document.documentElement.clientHeight
|
||||
|
||||
if (bottomOfWindow) {
|
||||
this.$store.dispatch('FetchReports')
|
||||
}
|
||||
handleScroll(reports) {
|
||||
const bottomOfWindow = document.documentElement.scrollHeight - document.documentElement.scrollTop === document.documentElement.clientHeight
|
||||
if (bottomOfWindow) {
|
||||
this.$store.dispatch('FetchReports')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue