Allow zoomed in images be closed by click outside - Add event listener to close image enlarge popup when clicked outside of image or description - Change img div to not be width:100% by default, was useless and just confusing when you could click next to the image and it zoomed in
| @@ -585,10 +585,12 @@ async function enlargeMessageImage() { | ||
| 585 | 585 | const imgHolder = document.createElement('div'); |
| 586 | 586 | imgHolder.classList.add('img_enlarged_holder'); |
| 587 | 587 | imgHolder.append(img); |
| 588 | 588 | const imgContainer = $('<div><pre><code class="img_enlarged_title"></code></code></pre></div>'); |
| 589 | 589 | imgContainer.prepend(imgHolder); |
| 590 | 590 | imgContainer.addClass('img_enlarged_container'); |
| 591 | - imgContainer.find('code').addClass('txt').text(title); | |
| 591 | + | |
| 592 | + const codeTitle = imgContainer.find('.img_enlarged_title'); | |
| 593 | + codeTitle.addClass('txt').text(title); | |
| 592 | 594 | const titleEmpty = !title || title.trim().length === 0; |
| 593 | 595 | imgContainer.find('pre').toggle(!titleEmpty); |
| 594 | 596 | addCopyToCodeBlocks(imgContainer); |
| @@ -598,9 +600,17 @@ async function enlargeMessageImage() { | ||
| 598 | 600 | popup.dlg.style.width = 'unset'; |
| 599 | 601 | popup.dlg.style.height = 'unset'; |
| 600 | 602 | |
| 601 | 603 | img.addEventListener('click', ()event => { |
| 602 | 604 | const shouldZoom = !img.classList.contains('zoomed'); |
| 603 | 605 | img.classList.toggle('zoomed', shouldZoom); |
| 606 | + event.stopPropagation(); | |
| 607 | + }); | |
| 608 | + codeTitle[0]?.addEventListener('click', event => { | |
| 609 | + event.stopPropagation(); | |
| 610 | + }); | |
| 611 | + | |
| 612 | + popup.dlg.addEventListener('click', event => { | |
| 613 | + popup.completeCancelled(); | |
| 604 | 614 | }); |
| 605 | 615 | |
| 606 | 616 | await popup.show(); |
| @@ -4799,7 +4799,7 @@ body:not(.sd) .mes_img_swipes { | ||
| 4799 | 4799 | |
| 4800 | 4800 | .img_enlarged { |
| 4801 | 4801 | object-fit: contain; |
| 4802 | 4802 | max-width: 100%; |
| 4803 | 4803 | height: 100%; |
| 4804 | 4804 | cursor: zoom-in |
| 4805 | 4805 | } |