Closed kud closed 10 years ago
Thanks for posting this, looking at it.
@kud I cannot reproduce it byt using the current version.
Here's what I have tested: using the https://github.com/vvo/lazyload/blob/master/examples/simple.html I change the uri of one image to a 404 one and then there's no infinite loop.
Do you have a 404 on the blank.gif or one the real image?
Browser ? Brower Version ? System ? Lazyload version ?
"lazyload": "git://github.com/vvo/lazyload#2.1.1" via npm
<img data-src="img.png"
src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
onload=lzld(this) onerror=lzld(this)>
I'm pretty sure it's because of onerror
, right?
oh yes that may be the case.
But with current version, using google chrome, using the simple example. Adding an onerror + changing to bad src result in no loop.
--- EDIT ---
I see the loop now
Onerror is only needed for IE8 compatibility when using data-uris (data uri generates an onerror so we then use it to know the blank image "loaded".
Either drop IE8 support Or use a b.gif and drop onerror handler
Ok found a fix and will publish it, thanks a lot @kud
;)
done @kud, published as v2.1.3 let me know
Thanks :D
Hello @vvo
I find that this change disables custom onerror
on <img>
tags
@fritx even when using addEventListener
?
@vvo haven't tried addEventListener
but I had to use onerror
:cry:
For what do you need onerror on lazyloaded images?
@vvo my teammate had an onerror="setMissingPic(this)"
, so we had to keep it..
How to deal with it without modification on your lib? :smile:
---- EDIT ----
And I tried to drop this change
It works but I don't know well what's the side-effect
maybe try onerror="setMissingPic(this);lzld(this)"
and in setMissingPic
set a new data-src.
Otherwise you can build your own lazyloader using https://github.com/vvo/in-viewport
Otherwise we would need to change the library
Thanks for your tips ;)
(sorry for the bad quality)