Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

fix firefox android bug (see #524) #527

Merged
merged 3 commits into from
Jun 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/plugins/gecko-picture/pf.gecko-picture.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* FF's first picture implementation is static and does not react to viewport changes, this tiny script fixes this.
*/
(function() {
(function(window) {
/*jshint eqnull:true */
var ua = navigator.userAgent;

Expand Down Expand Up @@ -36,21 +36,31 @@
var i;
var imgs = document.querySelectorAll("picture > img, img[srcset][sizes]");
for (i = 0; i < imgs.length; i++) {
if (imgs[i].currentSrc && !imgs[i].complete) {
removeEventListener("resize", onResize);
break;
}
fixRespimg(imgs[i]);
}
};
var onResize = function() {
clearTimeout(timer);
timer = setTimeout(findPictureImgs, 99);
};
var mq = window.matchMedia && matchMedia("(orientation: landscape)");
var init = function() {
onResize();

if (mq && mq.addListener) {
mq.addListener(onResize);
}
};

dummySrc.srcset = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";

if (/^[c|i]|d$/.test(document.readyState || "")) {
init();
} else {
document.addEventListener("DOMContentLoaded", init);
}

return onResize;
})());
}
})();
})(window);