From 9ca126f3cdf649afd487b80b460ca288226e0528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Tue, 20 Dec 2016 16:28:49 +0800 Subject: [PATCH] Add an offset to Below the fold images --- .../modules/lazyLoadableYLT/lazyLoadableYLT.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tools/phantomas/custom_modules/modules/lazyLoadableYLT/lazyLoadableYLT.js b/lib/tools/phantomas/custom_modules/modules/lazyLoadableYLT/lazyLoadableYLT.js index c3cfc45..8e2f042 100644 --- a/lib/tools/phantomas/custom_modules/modules/lazyLoadableYLT/lazyLoadableYLT.js +++ b/lib/tools/phantomas/custom_modules/modules/lazyLoadableYLT/lazyLoadableYLT.js @@ -26,7 +26,9 @@ exports.module = function(phantomas) { path, processedImages = {}, src, - viewportHeight = window.innerHeight; + viewportHeight = window.innerHeight, + // Add an offset of 100px under the height of the screen + LAZYLOAD_OFFSET = 100; phantomas.log('lazyLoadableImages: %d image(s) found, assuming %dpx offset to be the fold', len, viewportHeight); @@ -64,7 +66,7 @@ exports.module = function(phantomas) { Object.keys(processedImages).forEach(function(src) { var img = processedImages[src]; - if (img.offset > viewportHeight) { + if (img.offset > viewportHeight + LAZYLOAD_OFFSET) { phantomas.log('lazyLoadableImages: <%s> image (%s) is below the fold (at %dpx)', src, img.path, img.offset); phantomas.incrMetric('lazyLoadableImagesBelowTheFold');