-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@load - Not Firing - Nuxt 3 #682
Comments
For me it does not call load if the page is called directly or if you hit f5 while on the page. If the page is called from another page then it works as expected.
|
Same here. It seems like the images are cached. Hitting F5 doesn't call the event handler. Hitting ctrl-F5 (delete cache) calls the handler on 'some' images.... |
@pi0 could you have a look at #702 I fix the load listener it should now also work with picture as requested in #416 (comment) |
same here, fires only when images are lazy loaded and not inside the viewport on init. True does not work even with |
Any update on a fix being pushed to release? Currently blocking us going into production. |
+1 On this... same code running on Nuxt2 works fine 🥴 |
Wrapping with |
Please fix and tag as bug :) |
+1 for this... any progress about this issue? 🤔 |
A workaround work for me is use <script setup lang="ts">
const img = ref();
const emit = defineEmits(['load', 'error', 'animationend']);
onMounted(() => {
const element = img.value.$el as HTMLImageElement;
if (element) {
element.onerror = (event) => emit('error', event);
element.onanimationend = (event) => emit('animationend', event);
}
nextTick(() => {
if (!element || !element.complete) return;
emit('load');
if (element.naturalWidth === 0) {
emit('error');
}
});
});
</script>
<template>
<NuxtImg ref="img" v-bind="$attrs" @animationend="emit('animationend')" @error="emit('error')" @load="emit('load')" />
</template> |
This seems like a Vue issue, is that everyone else's impression as well? |
Note that This is effectively the same issue as #412. |
Ran into this again today, this is the solve for non-nuxt-image users: Template:
Script:
|
Really simple code:
<nuxt-img format="webp" src="/img/sleepiest-background.png" width="1593" height="717" :class="[backgroundLoaded == true ? 'opacity-100' : 'opacity-0', 'transition-opacity duration-200 ease-in-out']" @load="backgroundLoadComplete" />
Unfortunately the @load event isn't firing, and I'm not sure why.
Using Nuxt 3 (3.0.0) and @nuxt/image-edge (^1.0.0-27827328.bc9ddc0).
The text was updated successfully, but these errors were encountered: