From b63d2c24bdabbe6068f61016f306d46a6c06a8e9 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Sat, 24 May 2025 23:13:13 +0300 Subject: [PATCH] feat: autostart gif --- Web/static/js/al_wall.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 0c55c4b4..7d3b7139 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -2962,3 +2962,28 @@ u(document).on("submit", "#additional_fields_form", (e) => { } }) }) + +if(Number(localStorage.getItem('ux.gif_autoplay') ?? 0) == 1) { + const showMoreObserver = new IntersectionObserver(entries => { + entries.forEach(async x => { + doc_item = x.target.closest(".docGalleryItem") + if(doc_item.querySelector(".play-button") != null) { + if(x.isIntersecting) { + doc_item.classList.add("playing") + } else { + doc_item.classList.remove("playing") + } + } + }) + }, { + root: null, + rootMargin: '0px', + threshold: 0, + }) + + if(u('.docGalleryItem').length > 0) { + u('.docGalleryItem').nodes.forEach(item => { + showMoreObserver.observe(item) + }) + } +}