From 7845004840e3c9ca9789ad096fd62aced44aa1c2 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 1 Sep 2018 21:49:32 +0200 Subject: [PATCH] Fix scrolling --- src/components/Timeline.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 272748f..0848717 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -59,11 +59,8 @@ .then(() => { item._is_read = true }) - } - }, - - mounted() { - window.onscroll = () => { + }, + handleScroll() { // let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight === document.documentElement.offsetHeight; let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight === this.$el.offsetHeight + document.documentElement.offsetHeight + 20; if (bottomOfWindow) { @@ -94,6 +91,14 @@ } }) } + }, + + created() { + window.addEventListener('scroll', this.handleScroll); + }, + + destroyed() { + window.removeEventListener('scroll', this.handleScroll); } }