From 261d1d5ab5194827fe13743cb05a513306bf2b89 Mon Sep 17 00:00:00 2001 From: aFarkas Date: Wed, 24 Jun 2015 13:59:46 +0200 Subject: [PATCH 1/3] 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); From 5d4b85fa92aede8bc142b100df1a8a76a0d6f7e6 Mon Sep 17 00:00:00 2001 From: aFarkas Date: Wed, 24 Jun 2015 20:15:33 +0200 Subject: [PATCH 2/3] initialize gecko static picture fix on dom ready --- src/plugins/gecko-picture/pf.gecko-picture.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/gecko-picture/pf.gecko-picture.js b/src/plugins/gecko-picture/pf.gecko-picture.js index a6697f39..1fe8a93e 100644 --- a/src/plugins/gecko-picture/pf.gecko-picture.js +++ b/src/plugins/gecko-picture/pf.gecko-picture.js @@ -44,13 +44,20 @@ timer = setTimeout(findPictureImgs, 99); }; var mq = window.matchMedia && matchMedia("(orientation: landscape)"); + var init = function(){ + onResize(); - dummySrc.srcset = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; + if (mq && mq.addListener) { + mq.addListener(onResize); + } + }; - onResize(); + dummySrc.srcset = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (mq && mq.addListener) { - mq.addListener(onResize); + if (/^[c|i]|d$/.test(document.readyState || "")) { + init(); + } else { + document.addEventListener("DOMContentLoaded", init); } return onResize; From 0f975c7f1e204e6903af966321f4672a0075e697 Mon Sep 17 00:00:00 2001 From: aFarkas Date: Wed, 24 Jun 2015 20:16:30 +0200 Subject: [PATCH 3/3] fix code style --- src/plugins/gecko-picture/pf.gecko-picture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gecko-picture/pf.gecko-picture.js b/src/plugins/gecko-picture/pf.gecko-picture.js index 1fe8a93e..19d11f2a 100644 --- a/src/plugins/gecko-picture/pf.gecko-picture.js +++ b/src/plugins/gecko-picture/pf.gecko-picture.js @@ -44,7 +44,7 @@ timer = setTimeout(findPictureImgs, 99); }; var mq = window.matchMedia && matchMedia("(orientation: landscape)"); - var init = function(){ + var init = function() { onResize(); if (mq && mq.addListener) {