mirror of
https://github.com/directus/directus.git
synced 2026-01-24 16:07:59 -05:00
Fix v-image's intersection observer sometimes preventing image load (#15082)
* Fix v-image's intersection observer * check the last entry instead * clean up Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -25,15 +25,17 @@ const srcData = ref<string>(emptyPixel);
|
||||
|
||||
let loaded = false;
|
||||
|
||||
const observer = new IntersectionObserver(async (entries) => {
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
if (entries.length === 0) return;
|
||||
inView.value = entries[0].isIntersecting;
|
||||
|
||||
if (entries[0].isIntersecting && !loaded && props.src) {
|
||||
const isIntersecting = entries.at(-1)!.isIntersecting;
|
||||
|
||||
inView.value = isIntersecting;
|
||||
|
||||
if (isIntersecting && !loaded && props.src) {
|
||||
loadImage();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.src,
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user