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,20 +31,22 @@ export default {
}, },
mounted() { mounted() {
this.$store.dispatch('FetchReports') this.$store.dispatch('FetchReports')
this.scroll(this.reports) },
created() {
window.addEventListener('scroll', this.handleScroll)
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
}, },
methods: { methods: {
scroll(reports) { handleScroll(reports) {
window.onscroll = () => {
const bottomOfWindow = document.documentElement.scrollHeight - document.documentElement.scrollTop === document.documentElement.clientHeight const bottomOfWindow = document.documentElement.scrollHeight - document.documentElement.scrollTop === document.documentElement.clientHeight
if (bottomOfWindow) { if (bottomOfWindow) {
this.$store.dispatch('FetchReports') this.$store.dispatch('FetchReports')
} }
} }
} }
} }
}
</script> </script>
<style rel='stylesheet/scss' lang='scss' scoped> <style rel='stylesheet/scss' lang='scss' scoped>