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

Commit

Permalink
Merge pull request #527 from scottjehl/pf-gecko-static
Browse files Browse the repository at this point in the history
fix firefox android bug (see #524)
  • Loading branch information
Alexander Farkas committed Jun 24, 2015
2 parents 9d57582 + 0f975c7 commit 23ac273
Showing 1 changed file with 16 additions and 6 deletions.
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);

0 comments on commit 23ac273

Please sign in to comment.