-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Property onLoad$ of img tag not working with browser cache #4481
Comments
I guess when it's cached, the event is not dispatched on page load... not sure we can solve it from qwik |
maybe SSR iamges, you can just assumed they are loaded |
Hi, thanks for your qwik response.
On the other hand, I have investigated and it seems that there is no function in the browser api that returns if the image comes from the cache or from the network. Anyway, thanks for this wonderful framework, I really like the way it makes the developer's job so much easier 😉👍 |
@hilonegro52 I think using the simple example, inside of some const imgRef = useSignal<HTMLImageElement>();
useVisibleTask$(()=> {
imgRef.value!.decode().then(()=> {
console.log('loaded and ready!');
})
});
//other logic etc
return (<section>
<img ref=[imgRef} srf="some-source.png" height={200} width={200} />
</section>) |
good job!! It will definitely replace onLoad$ in everyday life. |
closing for #6246 where we need this as cookbook example |
Which component is affected?
Qwik Runtime
Describe the bug
I have a simple component with a jsx img tag where I use the onLoad$ property to render conditionally depending on whether the image is loaded or not. The issue is that when the image is cached in the browser the property doesn't work. In a browser with "private window" tab and cache off it works perfectly.
This happens in both Firefox and Chrome
If it helps i leave the code.
Reproduction
no url
Steps to reproduce
No response
System Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: