Fix image viewer cycling when some previews are hidden

This commit is contained in:
Jérémie Astori 2017-07-24 02:14:14 -04:00
parent 2a81af6949
commit 60b531a174
No known key found for this signature in database
GPG key ID: B9A4F245CD67BDE8

View file

@ -124,21 +124,21 @@ function openImageViewer(link) {
// Only expanded thumbnails are being cycled through.
// Previous image
let previousCandidates = link.closest(".preview").prev(".preview");
if (!previousCandidates.length) {
previousCandidates = link.closest(".msg").prevAll();
}
const previousImage = previousCandidates
let previousImage = link.closest(".preview").prev(".preview")
.find(".toggle-content.show .toggle-thumbnail").last();
if (!previousImage.length) {
previousImage = link.closest(".msg").prevAll()
.find(".toggle-content.show .toggle-thumbnail").last();
}
previousImage.addClass("previous-image");
// Next image
let nextCandidates = link.closest(".preview").next(".preview");
if (!nextCandidates.length) {
nextCandidates = link.closest(".msg").nextAll();
}
const nextImage = nextCandidates
let nextImage = link.closest(".preview").next(".preview")
.find(".toggle-content.show .toggle-thumbnail").first();
if (!nextImage.length) {
nextImage = link.closest(".msg").nextAll()
.find(".toggle-content.show .toggle-thumbnail").first();
}
nextImage.addClass("next-image");
$("#image-viewer").html(templates.image_viewer({