1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

Disconnects correctly

This commit is contained in:
Amir Raminfar
2020-06-15 16:42:04 -07:00
parent fc1e9588ec
commit 0ad19f7dde
3 changed files with 9 additions and 5 deletions

View File

@@ -44,20 +44,22 @@ export default {
},
mounted() {
const { content } = this.$refs;
new MutationObserver((e) => {
const mutationObserver = new MutationObserver((e) => {
if (!this.paused) {
this.scrollToBottom("instant");
} else {
this.hasMore = true;
}
}).observe(content, { childList: true, subtree: true });
});
mutationObserver.observe(content, { childList: true, subtree: true });
this.$once("hook:beforeDestroy", () => mutationObserver.disconnect());
const intersectionObserver = new IntersectionObserver(
(entries) => (this.paused = entries[0].intersectionRatio == 0),
{ threshholds: [0, 1], rootMargin: "80px 0px" }
);
intersectionObserver.observe(this.$refs.scrollObserver);
this.$once("hook:beforeDestroy", () => intersectionObserver.disconnect());
},
methods: {