Fix next/prev buttons in media viewer

This commit is contained in:
Pavel Djundik 2018-09-25 18:06:03 +03:00
parent 00b84d31f5
commit 99cda335ab

View File

@ -48,22 +48,22 @@ function openImageViewer(link, {pushState = true} = {}) {
// Previous image // Previous image
let previousImage = link.closest(".preview").prev(".preview") let previousImage = link.closest(".preview").prev(".preview")
.find(".toggle-content.show .toggle-thumbnail").last(); .find(".toggle-content .toggle-thumbnail").last();
if (!previousImage.length) { if (!previousImage.length) {
previousImage = link.closest(".msg").prevAll() previousImage = link.closest(".msg").prevAll()
.find(".toggle-content.show .toggle-thumbnail").last(); .find(".toggle-content .toggle-thumbnail").last();
} }
previousImage.addClass("previous-image"); previousImage.addClass("previous-image");
// Next image // Next image
let nextImage = link.closest(".preview").next(".preview") let nextImage = link.closest(".preview").next(".preview")
.find(".toggle-content.show .toggle-thumbnail").first(); .find(".toggle-content .toggle-thumbnail").first();
if (!nextImage.length) { if (!nextImage.length) {
nextImage = link.closest(".msg").nextAll() nextImage = link.closest(".msg").nextAll()
.find(".toggle-content.show .toggle-thumbnail").first(); .find(".toggle-content .toggle-thumbnail").first();
} }
nextImage.addClass("next-image"); nextImage.addClass("next-image");