From d55453a42d516a29dda790aa4f89e42b106c4524 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Mon, 13 Apr 2026 09:57:02 +0400 Subject: [PATCH] fixed adaptivity issue for transitions, added fades for navigation between pages without transitions --- frontend/next-env.d.ts | 2 +- .../Constructor/CanvasBackground.tsx | 22 +- .../Constructor/TransitionPreviewOverlay.tsx | 50 +++- .../src/components/RuntimePresentation.tsx | 226 +++++++++--------- frontend/src/config/canvas.config.ts | 6 +- frontend/src/css/main.css | 28 +++ frontend/src/hooks/useBackgroundTransition.ts | 126 ++++------ frontend/src/hooks/usePageSwitch.ts | 28 ++- frontend/src/pages/constructor.tsx | 29 +-- 9 files changed, 279 insertions(+), 238 deletions(-) diff --git a/frontend/next-env.d.ts b/frontend/next-env.d.ts index 254b73c..00a8785 100644 --- a/frontend/next-env.d.ts +++ b/frontend/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -/// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. diff --git a/frontend/src/components/Constructor/CanvasBackground.tsx b/frontend/src/components/Constructor/CanvasBackground.tsx index 98e662b..d223d44 100644 --- a/frontend/src/components/Constructor/CanvasBackground.tsx +++ b/frontend/src/components/Constructor/CanvasBackground.tsx @@ -15,8 +15,10 @@ interface CanvasBackgroundProps { backgroundVideoUrl?: string; backgroundAudioUrl?: string; previousBgImageUrl?: string; + previousBgVideoUrl?: string; isSwitching?: boolean; isNewBgReady?: boolean; + isFadingIn?: boolean; onBackgroundReady?: () => void; // Video playback settings videoAutoplay?: boolean; @@ -31,8 +33,10 @@ const CanvasBackground: React.FC = ({ backgroundVideoUrl, backgroundAudioUrl, previousBgImageUrl, + previousBgVideoUrl, isSwitching = false, isNewBgReady = false, + isFadingIn = false, onBackgroundReady, videoAutoplay = true, videoLoop = true, @@ -94,10 +98,12 @@ const CanvasBackground: React.FC = ({ )} - {/* Previous background overlay - shows during page switch until new bg is ready */} - {previousBgImageUrl && isSwitching && !isNewBgReady && ( + {/* Previous background overlays - show during loading AND crossfade. + Uses CSS animation for fade-out effect during crossfade. + z-0 keeps them BELOW new backgrounds (z-1). */} + {previousBgImageUrl && (isFadingIn || (isSwitching && !isNewBgReady)) && (
= ({ }} /> )} + {previousBgVideoUrl && (isFadingIn || (isSwitching && !isNewBgReady)) && ( +