Closed
Description
i use data srcset without src on image tag
<img width="120" height="86" src="" size-120x86 lazyload" alt="" data-full-width="1920" data-full-height="1272" data-src="http://localhost/photo-120x86.jpg" data-sizes="auto" data-srcset="http://localhost/photo-120x86.jpg 120w, http://localhost/photo-260x186.jpg 260w, http://localhost/photo-350x250.jpg 350w" data-expand="-20" />
but loaded class added too early (not when image loaded, but when image get the view). its working fine on chrome & microsoft edge. but not on firefox.
Metadata
Metadata
Assignees
Labels
No labels
Activity
aFarkas commentedon Jan 6, 2017
I would need a simplified testcase on codepen, jsfiddler, jsbin or what you want.
jegbagus commentedon Jan 6, 2017
hi aFarkas, thank you for replying.
Please take a look right here. https://jsfiddle.net/432zy2en/
on google chrome, when you scroll down, animation is smooth because lazyloaded class added correctly after image loaded.
but if you try it on firefox, it will flashing. it may because lazyloaded class added before image loaded.
Thank you
jegbagus commentedon Jan 7, 2017
hi aFarkas, i solve this issues by adding additional function when checking if image already loaded.
previously image directly checked with complete property attached to element. to fix this issues on firefox it will need additional check if image is truly loaded.
into this one :
with this function i get from stackoverflow :
check elem.complete after rAF (fixes #342)
aFarkas commentedon Jan 14, 2017
I found a better solution for this. FF does not synchronously update
img.complete
aftersrc
/srcset
was changed tofalse
, but it is updated in the task after. Due to the fact, that we already work with rAF here, it was easy to fix. I additionally guarded this usingnaturalWidth > 1
, so this also works with a data uri image.chpio commentedon Mar 20, 2019
this isn't fixed for me, the img isn't fully loaded after the
lazyloaded
event was fired.i still need to workaround that by adding an onload listener: