Merge pull request #413 from YunoHost/fix-app-catalog-rendering

ugly fix LazyRenderer bug
This commit is contained in:
Alexandre Aubin 2021-11-05 02:32:14 +01:00 committed by GitHub
commit ddd268cbb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,8 +27,19 @@ export default {
mounted () { mounted () {
let unrenderTimer let unrenderTimer
let renderTimer let renderTimer
this.observer = new IntersectionObserver(entries => { 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) clearTimeout(unrenderTimer)
// Show the component after a delay (to avoid rendering while scrolling fast) // Show the component after a delay (to avoid rendering while scrolling fast)
renderTimer = setTimeout(() => { renderTimer = setTimeout(() => {