diff options
| author | 2025-08-27 01:37:04 +0700 | |
|---|---|---|
| committer | 2025-08-27 01:37:04 +0700 | |
| commit | ea8c6da9b8bafa1d4e5fe5a77fb306006db7d6f6 (patch) | |
| tree | 02377a21a94ded0a33315817d139f739c75a7013 /internal | |
| parent | b0ab2ed92870d8c651267db10d68eb695da2ec62 (diff) | |
| download | web-ea8c6da9b8bafa1d4e5fe5a77fb306006db7d6f6.tar.gz web-ea8c6da9b8bafa1d4e5fe5a77fb306006db7d6f6.zip | |
feat: update galleries on resize (with smooth animations this time)
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/lightgallery/html_renderer.go | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/internal/lightgallery/html_renderer.go b/internal/lightgallery/html_renderer.go index e20e9ec..17a6f2b 100644 --- a/internal/lightgallery/html_renderer.go +++ b/internal/lightgallery/html_renderer.go @@ -92,32 +92,35 @@ func (r *LightGalleryHTMLRenderer) renderLightGallery(w util.BufWriter, source [ w.WriteString(fmt.Sprintf(` <script> function createLightGallery%s() { - const $lgContainer = document.getElementById('lg-%s'); - const inlineGallery = lightGallery($lgContainer, { - container: $lgContainer, - dynamic: true, - dynamicEl: [%s], - width: "100%%", - height: "50vmin", - hash: false, - closable: false, - showMaximizeIcon: true, - appendSubHtmlTo: ".lg-sub-html", - isMobile: () => false, - slideDelay: 0, - plugins: [lgZoom, lgThumbnail], - thumbWidth: calculateVmin(10), - thumbHeight: "10vmin", - thumbMargin: 4 - }); + const $lgContainer = document.getElementById('lg-%s'); + const config = { + container: $lgContainer, + dynamic: true, + dynamicEl: [%s], + width: "100%%", + height: "50vmin", + hash: false, + closable: false, + showMaximizeIcon: true, + appendSubHtmlTo: ".lg-sub-html", + isMobile: () => false, + slideDelay: 0, + plugins: [lgZoom, lgThumbnail], + thumbWidth: calculateVmin(10), + thumbHeight: "10vmin", + thumbMargin: 4 + }; + const inlineGallery = lightGallery($lgContainer, config); - setTimeout(() => { - inlineGallery.openGallery(); - }, 200); + setTimeout(() => { + inlineGallery.openGallery(); + }, 200); + + galleryMap.set(inlineGallery, createLightGallery%s); } document.addEventListener('DOMContentLoaded', createLightGallery%s); -</script>`, galleryID, galleryID, strings.Join(dynamicElements, ","), galleryID)) +</script>`, galleryID, galleryID, strings.Join(dynamicElements, ","), galleryID, galleryID)) } return ast.WalkContinue, nil |