Skip to content

Commit

Permalink
Reposition of plugin.setCaption() (#37)
Browse files Browse the repository at this point in the history
The new Caption should show up immediately without waiting for its corresponding image to load.
Otherwise it would be misleading watching(reading again) the old caption while waiting for the new image to load.

Co-authored-by: TheCrazyProgrammer <[email protected]>
  • Loading branch information
TheCrazyProgrammer and TheCrazyProgrammer authored Nov 30, 2020
1 parent af3b48c commit 8ae65a0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions jquery.lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@
plugin.lightbox.fadeIn('fast').append('<span class="lightbox__loading"></span>');

var img = $('<img src="' + $(plugin.current).attr('href') + '" draggable="false">');

plugin.setCaption();
$(img).on('load', function () {
$('.lightbox__loading').remove();
plugin.lightbox.append(img);
plugin.image = $("img", plugin.lightbox).hide();
plugin.resizeImage();
plugin.setCaption();
});
},

Expand Down Expand Up @@ -213,4 +212,4 @@
plugin.init(this);
};

})(jQuery);
})(jQuery);

0 comments on commit 8ae65a0

Please sign in to comment.