Skip to content

Commit

Permalink
Fixed issue with lazyloading; #1889
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaaarc committed Nov 28, 2018
1 parent b43f991 commit 9aff29f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions core/lazyload/resources/lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,20 @@
var loadVisibleImages = function () {
var visibleImages = getVisibleImages();

$(visibleImages).each(function (index) {
$(visibleImages).each(function () {
// Generate a new image, add the source so it starts loading
var $loadImage = $('<img/>', {
src: this.source
});

var image = this;
var imageIndex = images.map(function(e) { return e.id; }).indexOf(image.id);

// If the image was loaded successfully
$loadImage.on('load', function () {
// Remove the image from the images array because it's not
// needed anymore
delete images[index];
delete images[imageIndex];

var $image = $('.' + settings.imageIdentifierPrefix + image.id);
var $placeholder = $image.next('.' + settings.placeholderClass);
Expand Down Expand Up @@ -208,7 +209,7 @@

// If the image can't be loaded
$loadImage.on('error', function () {
delete images[index];
delete images[imageIndex];

// Trigger a error event
$(document).trigger("lazyimage-loaded", {
Expand Down
2 changes: 1 addition & 1 deletion core/lazyload/resources/lazyload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9aff29f

Please sign in to comment.