Vanilla-lazyload: Background image lazy load and callbacks

Created on 14 Oct 2019  路  3Comments  路  Source: verlok/vanilla-lazyload

Hello,
I saw in docs, callback_finish wont be fired and load class will not ba added into bg images.
I also tried other hooks like callback_finish with no luck. Is there a way to add class or some callback after BG image is loaded?

I'd like to make transition between placeholder and new loaded BG.

Thanks :)

By now Im using just stying with attribute &[data-was-processed="true"] { since this is added after image is loaded, but if it is added, maybe there is way to add something else with some callbacks?

Question

Most helpful comment

Hey @isuke01, @wamk9,
things changed on version 15.

I found a way to manage background images's load/error event, so now background images are now getting the loaded or error class and calling callback_loaded and callback_error.

Take a look at the changelog and to the upgrading guide if you're interested.

Have a nice day.

All 3 comments

Is there a way to add class or some callback after BG image is loaded?

You can try using callback_reveal, it fires when div or img appears on screen, the callback_finish fires when all images is loaded (is saying on docs but i don't see this happens).

See this code and this demo.

Ok, thanks

Hey @isuke01, @wamk9,
things changed on version 15.

I found a way to manage background images's load/error event, so now background images are now getting the loaded or error class and calling callback_loaded and callback_error.

Take a look at the changelog and to the upgrading guide if you're interested.

Have a nice day.

Was this page helpful?
0 / 5 - 0 ratings