Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Merge 67da054 into 12041cc
Browse files Browse the repository at this point in the history
  • Loading branch information
collin committed Sep 14, 2015
2 parents 12041cc + 67da054 commit e7a309b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions betty/cropper/templates/image.js
Expand Up @@ -34,7 +34,10 @@
}
w.picturefill = function(elements, forceRerender) {
// It is sometimes desirable to scroll without loading images as we go.
if (w.pauseBettyCroppyPicturefill) {
return;
}
// get elements to picturefill
var ps;
if (elements instanceof Array) {
Expand All @@ -57,9 +60,11 @@
}
// check if image is in viewport for lazy loading, and
// preload images if they're within 100px of being shown.
var innerHeight = w.innerHeight || w.document.documentElement.clientHeight,
visible = el.getBoundingClientRect().top <= (innerHeight + 250);
// preload images if they're within 100px of being shown above scroll,
// within 250px of being shown below scroll.
var elementRect = el.getBoundingClientRect(),
innerHeight = w.innerHeight || w.document.documentElement.clientHeight,
visible = elementRect.top <= (innerHeight + 250) && elementRect.top >= -100;
// this is a div to picturefill, start working on it if it hasn't been rendered yet
if (el.getAttribute("data-image-id") !== null
Expand Down Expand Up @@ -211,4 +216,4 @@

}

}(this));
}(this));

0 comments on commit e7a309b

Please sign in to comment.