Merge pull request #2908 from SillyTavern/gallery-improvements Improve gallery layout
Signed| @@ -26,9 +26,11 @@ let paginationVisiblePages = 10; | ||
| 26 | 26 | let paginationMaxLinesPerPage = 2; |
| 27 | 27 | let galleryMaxRows = 3; |
| 28 | 28 | |
| 29 | -$('body').on('click', '.dragClose', function () { | |
| 29 | +// Remove all draggables associated with the gallery | |
| 30 | - const relatedId = $(this).data('related-id'); // Get the ID of the related draggable | |
| 30 | +$('#movingDivs').on('click', '.dragClose', function () { | |
| 31 | - $(`body > .draggable[id="${relatedId}"]`).remove(); // Remove the associated draggable | |
| 31 | + const relatedId = $(this).data('related-id'); | |
| 32 | + if (!relatedId) return; | |
| 33 | + $(`#movingDivs > .draggable[id="${relatedId}"]`).remove(); | |
| 32 | 34 | }); |
| 33 | 35 | |
| 34 | 36 | const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved'; |
| @@ -290,7 +292,7 @@ function makeMovable(id = 'gallery') { | ||
| 290 | 292 | |
| 291 | 293 | $('#dragGallery').css('display', 'block'); |
| 292 | 294 | |
| 293 | 295 | $('body#movingDivs').append(newElement); |
| 294 | 296 | |
| 295 | 297 | loadMovingUIState(); |
| 296 | 298 | $(`.draggable[forChar="${id}"]`).css('display', 'block'); |
| @@ -362,8 +364,8 @@ function makeDragImg(id, url) { | ||
| 362 | 364 | } |
| 363 | 365 | } |
| 364 | 366 | |
| 365 | 367 | // Step 3: Attach it to the bodymovingDivs container |
| 366 | 368 | document.bodygetElementById('movingDivs').appendChild(newElement); |
| 367 | 369 | |
| 368 | 370 | // Step 4: Call dragElement and loadMovingUIState |
| 369 | 371 | const appendedElement = document.getElementById(uniqueId); |
| @@ -5386,13 +5386,6 @@ body:not(.movingUI) .drawer-content.maximized { | ||
| 5386 | 5386 | |
| 5387 | 5387 | /* Jank mobile support for gallery and future draggables */ |
| 5388 | 5388 | @media screen and (max-width: 1000px) { |
| 5389 | - #gallery { | |
| 5390 | - display: block; | |
| 5391 | - width: 100vw; | |
| 5392 | - height: 100vh; | |
| 5393 | - z-index: 9999; | |
| 5394 | - } | |
| 5395 | - | |
| 5396 | 5389 | .draggable { |
| 5397 | 5390 | display: block; |
| 5398 | 5391 | width: 100vw; |