mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 22:10:22 +00:00
Merge pull request #1367 from thelounge/astorije/fix-viewer-cycle
Fix image viewer cycling when some previews are hidden
This commit is contained in:
commit
8259b0924b
1 changed files with 10 additions and 10 deletions
|
@ -126,21 +126,21 @@ function openImageViewer(link) {
|
||||||
// Only expanded thumbnails are being cycled through.
|
// Only expanded thumbnails are being cycled through.
|
||||||
|
|
||||||
// Previous image
|
// Previous image
|
||||||
let previousCandidates = link.closest(".preview").prev(".preview");
|
let previousImage = link.closest(".preview").prev(".preview")
|
||||||
if (!previousCandidates.length) {
|
|
||||||
previousCandidates = link.closest(".msg").prevAll();
|
|
||||||
}
|
|
||||||
const previousImage = previousCandidates
|
|
||||||
.find(".toggle-content.show .toggle-thumbnail").last();
|
.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");
|
previousImage.addClass("previous-image");
|
||||||
|
|
||||||
// Next image
|
// Next image
|
||||||
let nextCandidates = link.closest(".preview").next(".preview");
|
let nextImage = link.closest(".preview").next(".preview")
|
||||||
if (!nextCandidates.length) {
|
|
||||||
nextCandidates = link.closest(".msg").nextAll();
|
|
||||||
}
|
|
||||||
const nextImage = nextCandidates
|
|
||||||
.find(".toggle-content.show .toggle-thumbnail").first();
|
.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");
|
nextImage.addClass("next-image");
|
||||||
|
|
||||||
imageViewer.html(templates.image_viewer({
|
imageViewer.html(templates.image_viewer({
|
||||||
|
|
Loading…
Reference in a new issue