Dynamically displayed images require a scroll to fire layzr
Subfader opened this issue · comments
Martin commented
I have images that I display on click. But I need to animate a scroll to fire layzr.
How can this be avoided?
Martin commented
I'm doing manual attribute swapping for src on click now.
Would be good to know nontheless, it's a bug imo.
Michael Cavalea commented
tho its usually called via the scroll handler, you can call the update
function on your instance manually when you add the image source. let me know how it works out for you
// create your instance (you only need 1 master instance, not 1 per image)
var instance = new Layzr()
// in the click handler that reveals the image
button.addEventListener('click', function() {
// call layzr's update method manually
instance.update()
})