From 04e5c5a00999f50d9086bea4c34521eafab95ee3 Mon Sep 17 00:00:00 2001 From: Morten Winther Olsson Date: Tue, 17 Apr 2018 21:23:19 +0200 Subject: [PATCH] Bug fix for onload race condition Proposed fix for bug illustrated on https://jsfiddle.net/olwimo/h633q2re/ Please note that this is a quick&dirty fix off the top of my head, and I haven't done any testing yet; I'll do a few quick tests soon, just to be sure I haven't missed some obvious fault/better solution, but I'm not too familiar with lightbox, so it's better if you guys find the "right" way to fix it anyway - I just didn't want to report the bug without at least suggesting a way to fix it. --- src/js/lightbox.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/lightbox.js b/src/js/lightbox.js index 5b8785aa..0a5b08e8 100644 --- a/src/js/lightbox.js +++ b/src/js/lightbox.js @@ -265,6 +265,7 @@ // Hide most UI elements in preparation for the animated resizing of the lightbox. Lightbox.prototype.changeImage = function(imageNumber) { var self = this; + var album = this.album; this.disableKeyboardNav(); var $image = this.$lightbox.find('.lb-image'); @@ -288,8 +289,8 @@ var windowWidth; $image.attr({ - 'alt': self.album[imageNumber].alt, - 'src': self.album[imageNumber].link + 'alt': album[imageNumber].alt, + 'src': album[imageNumber].link }); $preloader = $(preloader); @@ -333,7 +334,7 @@ self.sizeContainer($image.width(), $image.height()); }; - preloader.src = this.album[imageNumber].link; + preloader.src = album[imageNumber].link; this.currentImageIndex = imageNumber; };