feature: nieskończona lista historii dr/rj scenerii

This commit is contained in:
2023-06-24 13:46:37 +02:00
parent 6ceae3f161
commit 96d64e77fc
3 changed files with 72 additions and 13 deletions
+24
View File
@@ -0,0 +1,24 @@
import { defineComponent } from 'vue';
export default defineComponent({
data: () => ({
observer: null as IntersectionObserver | null,
observerTarget: null as Element | null,
}),
methods: {
mountObserver(actionFunction: () => void, target: Element) {
this.observer = new IntersectionObserver((entries) => {
if (entries[0].intersectionRatio > 0) actionFunction();
});
this.observer.observe(target);
},
unmountObserver() {
if (!this.observerTarget) return;
this.observer?.unobserve(this.observerTarget);
},
},
});