Fix on scroll event

This commit is contained in:
Angelina Filippova 2019-05-25 01:45:05 +02:00
parent 7b4184cbde
commit 93866e78ae

View file

@ -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')
}
}
}