I have a GatsbyImage / StaticImage component and I use the onLoad event to trigger an animation. But once the browser has cached the image, the onLoad event never fires again. So if you visit a different page and then return, the animation isn't triggered.
The usual workaround with an ordinary image would be to attach a ref and then check ref.current.complete to see if the image had loaded. But GatsbyImage refuses to take a ref.
So
- Is there any way to add a ref to the
GatsbyImagecomponent? - Is there any other way to detect if the image has loaded?
- Is the only alternative to use an ordinary
imgtag (and lose out on all the gatsby image magic)?