Skip to content

Commit

Permalink
Fix Safari Back-Forward Cache issue with lazyloading image elements (f…
Browse files Browse the repository at this point in the history
…ixes #711)
  • Loading branch information
aFarkas committed Oct 26, 2019
1 parent 2af744a commit 7a7f5d9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog

## x

* Fix Safari Back-Forward Cache issue with lazyloading image elements (fixes [#711](https://github.com/aFarkas/lazysizes/issues/711))
* Add lazyload of autoplay videos to unveilhooks (fixes [#697](https://github.com/aFarkas/lazysizes/issues/697))

## 5.1.2

Fix visibility check (fixes [#709](https://github.com/aFarkas/lazysizes/issues/709))
* Fix visibility check (fixes [#709](https://github.com/aFarkas/lazysizes/issues/709))

## 5.1.1

Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
minified: {
options: {
maxBytes: (1024 * 7)
maxBytes: (1024 * 7.5)
},
src: ["lazysizes.min.js"]
}
Expand Down
16 changes: 16 additions & 0 deletions lazysizes-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,22 @@

addEventListener('resize', throttledCheckElements, true);

addEventListener('pageshow', function (e) {
if (e.persisted) {
var loadingElements = document.querySelectorAll('.' + lazySizesCfg.loadingClass);

if (loadingElements.length && loadingElements.forEach) {
requestAnimationFrame(function () {
loadingElements.forEach( function (img) {
if (img.complete) {
unveilElement(img);
}
});
});
}
}
});

if(window.MutationObserver){
new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
} else {
Expand Down
2 changes: 1 addition & 1 deletion lazysizes-umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lazysizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,22 @@

addEventListener('resize', throttledCheckElements, true);

addEventListener('pageshow', function (e) {
if (e.persisted) {
var loadingElements = document.querySelectorAll('.' + lazySizesCfg.loadingClass);

if (loadingElements.length && loadingElements.forEach) {
requestAnimationFrame(function () {
loadingElements.forEach( function (img) {
if (img.complete) {
unveilElement(img);
}
});
});
}
}
});

if(window.MutationObserver){
new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
} else {
Expand Down
Loading

0 comments on commit 7a7f5d9

Please sign in to comment.