mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Cleanup scroll listener.
This commit is contained in:
parent
02f0f94aee
commit
6d2a174a67
1 changed files with 15 additions and 12 deletions
|
@ -57,14 +57,20 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchFeed().then(videos => {
|
this.fetchFeed().then(videos => {
|
||||||
this.videosStore = videos;
|
this.videosStore = videos;
|
||||||
this.loadMoreVideos()
|
this.loadMoreVideos();
|
||||||
this.updateWatched(this.videos);
|
this.updateWatched(this.videos);
|
||||||
this.watchScroll()
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
document.title = this.$t("titles.feed") + " - Piped";
|
document.title = this.$t("titles.feed") + " - Piped";
|
||||||
if (this.videos.length > 0) this.updateWatched(this.videos);
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
||||||
|
window.addEventListener("scroll", this.handleScroll);
|
||||||
|
},
|
||||||
|
deactivated() {
|
||||||
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchFeed() {
|
async fetchFeed() {
|
||||||
|
@ -89,17 +95,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadMoreVideos() {
|
loadMoreVideos() {
|
||||||
this.currentVideoCount = this.currentVideoCount + this.videoStep
|
this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
|
||||||
this.videos = this.videosStore.slice(0, this.currentVideoCount);
|
if (this.videos.length != this.videosStore.length)
|
||||||
|
this.videos = this.videosStore.slice(0, this.currentVideoCount);
|
||||||
},
|
},
|
||||||
watchScroll () {
|
handleScroll() {
|
||||||
window.onscroll = () => {
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
||||||
if (document.body.scrollHeight ==
|
this.loadMoreVideos();
|
||||||
document.documentElement.scrollTop +
|
|
||||||
window.innerHeight) {
|
|
||||||
this.loadMoreVideos()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue