From 55d309b2d7a3d681546f161d0299d7cd94c0d484 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 7 Jul 2025 15:37:24 +0200 Subject: [PATCH] Changed fade between html iframe animation --- app/static/js/iframe.js | 108 ++++++++++++++++-------------- app/templates/moduls/base.html.j2 | 5 ++ 2 files changed, 62 insertions(+), 51 deletions(-) diff --git a/app/static/js/iframe.js b/app/static/js/iframe.js index 2cb199d..71736f9 100644 --- a/app/static/js/iframe.js +++ b/app/static/js/iframe.js @@ -21,71 +21,77 @@ function syncIframeHeight() { } } -// Function to open a URL in an iframe +// Function to open a URL in an iframe (jQuery version mit 1500 ms Fade) function openIframe(url) { - enterFullscreen() - // Hide the container (and its scroll-container) so the iframe can appear in its place - if (scrollbarContainer) { - scrollbarContainer.style.display = 'none'; - } + enterFullscreen(); - // Hide any custom scrollbar element if present - if (customScrollbar) { - customScrollbar.style.display = 'none'; - } + var $container = scrollbarContainer ? $(scrollbarContainer) : null; + var $customScroll = customScrollbar ? $(customScrollbar) : null; + var $main = $(mainElement); - // Create or retrieve the iframe in the main element - let iframe = mainElement.querySelector("iframe"); - if (!iframe) { - iframe = document.createElement("iframe"); - iframe.width = "100%"; - iframe.style.border = "none"; - iframe.style.overflow = "auto"; // Enable internal scrolling - iframe.scrolling = "auto"; - mainElement.appendChild(iframe); - syncIframeHeight(); - } + // Original-Content ausblenden mit 1500 ms + var promises = []; + if ($container) promises.push($container.fadeOut(1500).promise()); + if ($customScroll) promises.push($customScroll.fadeOut(1500).promise()); - // Set the iframe's source URL - iframe.src = url; + $.when.apply($, promises).done(function() { + // Iframe anlegen, falls noch nicht vorhanden + var $iframe = $main.find('iframe'); + if ($iframe.length === 0) { + originalMainStyle = $main.attr('style') || null; + $iframe = $('