Sha256: 7bb69cf9ffe9bcbb3016bd95b0e7c472cad7077ff161274aa5237a9c2b0ef0be

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

/**
 * FF's first picture implementation is static and does not react to viewport changes, this tiny script fixes this.
 */
(function(){
	/*jshint eqnull:true */
	var ua = navigator.userAgent;

	if(window.HTMLPictureElement && ((/ecko/).test(ua) && ua.match(/rv\:(\d+)/) && RegExp.$1 < 41)){
		addEventListener('resize', (function(){
			var timer;

			var dummySrc = document.createElement('source');

			var fixPicture = function(img){
				var picture = img.parentNode;
				var source = dummySrc.cloneNode();
				picture.insertBefore(source, picture.firstElementChild);
				setTimeout(function(){
					picture.removeChild(source);
				});
			};

			var findPictureImgs = function(){
				var i;
				var imgs = document.querySelectorAll('picture > img');
				for(i = 0; i < imgs.length; i++){
					if(imgs[i].complete){
						if(imgs[i].currentSrc){
							fixPicture(imgs[i]);
						}
					} else if(imgs[i].currentSrc){
						removeEventListener('resize', onResize);
						break;
					}
				}
			};
			var onResize = function(){
				clearTimeout(timer);
				timer = setTimeout(findPictureImgs, 99);
			};

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

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

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
mifflin-0.1.1 vendor/assets/bower_components/picturefill/dist/plugins/gecko-picture/pf.gecko-picture.js
mifflin-0.1.1 vendor/assets/bower_components/picturefill/src/plugins/gecko-picture/pf.gecko-picture.js