mlisook / plastic-image

A Polymer 3.0 element which adds extra plasticity to <iron-image> with support for srcset and lazy loading
MIT License
30 stars 6 forks source link

Adddress issues 20-23 #24

Closed mlisook closed 7 years ago

mlisook commented 7 years ago

Addresses 4 issues:

Issue #20 - To improve performance, stop observing intersections after lazy load is triggered. Issue #21 - Do not destroy the intersection observer instance. Not only is it not necessary, but destroying it is one pathway to cause Issue #22. Issue #22 - In the Firefox browser the disconnectedCallback is often called twice. This led to the count of elements sharing the observer instance to be wrong and a new instance built. A few more side effects later (e.g. disconnects could overlap with new connects) the _lazyLoadCallback wouldn't be called for some elements and they would then not load. This can be seen with some effort in scenarios like PWA or SPA or data binding to a substantial list of images in dom-repeat. The change avoids dropping the observer and doesn't do anything with the count any longer. Issue #23 - Edge doesn't reliably dispatch scroll events. This is especially true on touchpad and touchscreen computers, but also occurs to a lesser extent on any PC. To work around this browser deficiency that has at least a dozen open issues many over a year old on the Edge issue tracker, a dependency on ua-parser-js is added. The UA Parser is loaded if the IntersectionObserver polyfill is loaded, and if the browser is Edge, a polling interval of 300 ms is set (normally there is no polling).