From 2af253ae3ef18dcb35d03c80d73917769a37917a Mon Sep 17 00:00:00 2001 From: axolotle Date: Thu, 4 Nov 2021 17:12:09 +0100 Subject: [PATCH] ugly fix LazyRenderer bug --- app/src/components/LazyRenderer.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/components/LazyRenderer.vue b/app/src/components/LazyRenderer.vue index bb764f93..399b6c9b 100644 --- a/app/src/components/LazyRenderer.vue +++ b/app/src/components/LazyRenderer.vue @@ -27,8 +27,19 @@ export default { mounted () { let unrenderTimer let renderTimer + this.observer = new IntersectionObserver(entries => { - if (entries[0].isIntersecting) { + let intersecting = entries[0].isIntersecting + + // Fix for weird bug when typing fast in app search or on slow client. + // Intersection is triggered but even if the element is indeed in the viewport, + // isIntersecting is `false`, so we have to manually check this… + // FIXME Would be great to find out why this is happening + if (!intersecting && this.$el.offsetTop < window.innerHeight) { + intersecting = true + } + + if (intersecting) { clearTimeout(unrenderTimer) // Show the component after a delay (to avoid rendering while scrolling fast) renderTimer = setTimeout(() => {