qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[📖] onLoad$ img cookbook

Open PatrickJS opened this issue 1 year ago • 0 comments

Suggestion

document a better way to detect onLoad for images https://github.com/QwikDev/qwik/issues/4481

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>
);

PatrickJS avatar May 06 '24 16:05 PatrickJS