joeyvandijk / rimg

[DEPRECATED] A responsive image solution for browsers that support mediaqueries. Pure javascript and no server-side code.
http://joeyvandijk.github.io/rimg
MIT License
294 stars 25 forks source link

Loading animation #16

Open klemens-u opened 8 years ago

klemens-u commented 8 years ago

It would be very nice to have a loading progress animation. Currently if you scroll down quickly the are a lot of blank "holes" in den page (still unloaded images) which is rather confusing for the visitor. Any ideas?

joeyvandijk commented 8 years ago

Broadcasting JS events would be the obvious choice, but depending on browser support this will add extra bloat to Rimg. I think I need to rewrite some stuff to re-evaluate which features to support in Rimg and which would be the best approach. Until then I would advise to do something like:

img:not([src]) { /* CSS animation code*/}

but I understand that when the load starts I need to do something. Perhaps I can add a class to show the progress part and remove when it is finished.

klemens-u commented 8 years ago

Yes, JS events would be very nice. Your css does not work for me as I always assign src with a small blank inline image because I need validated html. (src is mandatory)

But it inspired me to come up with a different solution which solves two issues for me at once. I now use a loading gif as src. So on one hand src is'nt empty, on the other hand the loading animation is shown until rimg loads the correct image.

joeyvandijk commented 8 years ago

That works even better (for now), will focus on css-classes while JS-events add to much bloat (due to exceptions).