From 261d1d5ab5194827fe13743cb05a513306bf2b89 Mon Sep 17 00:00:00 2001 From: aFarkas Date: Wed, 24 Jun 2015 13:59:46 +0200 Subject: [PATCH] try to fix firefox android bug (see #524) --- src/plugins/gecko-picture/pf.gecko-picture.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/gecko-picture/pf.gecko-picture.js b/src/plugins/gecko-picture/pf.gecko-picture.js index e93ca84f..a6697f39 100644 --- a/src/plugins/gecko-picture/pf.gecko-picture.js +++ b/src/plugins/gecko-picture/pf.gecko-picture.js @@ -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; @@ -36,10 +36,6 @@ 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]); } }; @@ -47,10 +43,17 @@ clearTimeout(timer); timer = setTimeout(findPictureImgs, 99); }; + var mq = window.matchMedia && matchMedia("(orientation: landscape)"); dummySrc.srcset = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; + onResize(); + + if (mq && mq.addListener) { + mq.addListener(onResize); + } + return onResize; })()); } -})(); +})(window);