toddmotto / echo

Lazy-loading images with data-* attributes

Home Page:http://toddmotto.com/labs/echo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scroll event handler should not be detached in render method.

ladjzero opened this issue · comments

I'm working on such case, rendering item views of a listview asynchronously. echo was initialized as soon as DOMContentLoaded, and then item views were rendered one by one.

It turns out that scroll event handler may be detached if length of document.querySelectorAll('img[data-echo], [data-echo-background]') is 0.

It would be better that the scroll event handler was kept as it is. Because the nodes in the method render is not cached at all. Every time the render method is called, the nodes can be updated. While nodes.length > 0, scroll handler can be called.

I use the release 1.7.3