From 60b531a174e6f99c6913184ebc379bf314e44566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 24 Jul 2017 02:14:14 -0400 Subject: [PATCH] Fix image viewer cycling when some previews are hidden --- client/js/renderPreview.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index b2229bec..fda8759f 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -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({