danylokhodus commited on
Commit
d7ddf0b
·
1 Parent(s): f0bf30e

feat: hold loading screen overlay until fitView centering has finished in the background

Browse files
Files changed (1) hide show
  1. src/pages/CanvasPage.jsx +5 -2
src/pages/CanvasPage.jsx CHANGED
@@ -2138,11 +2138,13 @@ const CanvasInner = () => {
2138
  isLoading
2139
  } = useCanvasLogic(id, user);
2140
 
 
2141
  const hasFittedRef = useRef(false);
2142
 
2143
  // Reset the fitted flag when the project ID changes
2144
  useEffect(() => {
2145
  hasFittedRef.current = false;
 
2146
  }, [id]);
2147
 
2148
  useEffect(() => {
@@ -2150,7 +2152,8 @@ const CanvasInner = () => {
2150
  const timer = setTimeout(() => {
2151
  fitView({ maxZoom: 1.0, padding: 0.1 });
2152
  hasFittedRef.current = true;
2153
- }, 100);
 
2154
  return () => clearTimeout(timer);
2155
  }
2156
  }, [nodes, fitView]);
@@ -2770,7 +2773,7 @@ const CanvasInner = () => {
2770
  <Sidebar />
2771
 
2772
  <main className="flex-grow flex flex-col relative text-primary">
2773
- {isLoading && (
2774
  <div className="absolute inset-0 bg-background flex flex-col items-center justify-center z-[60] animate-fade-in">
2775
  <div className="flex flex-col items-center gap-6 p-8 bg-surface-container-lowest border-4 border-primary rounded-3xl shadow-[8px_8px_0px_0px_var(--color-primary)] max-w-sm w-full mx-4 text-center">
2776
  {/* Stylized Neo-brutalist / Sketch spinner */}
 
2138
  isLoading
2139
  } = useCanvasLogic(id, user);
2140
 
2141
+ const [isVisualizing, setIsVisualizing] = useState(false);
2142
  const hasFittedRef = useRef(false);
2143
 
2144
  // Reset the fitted flag when the project ID changes
2145
  useEffect(() => {
2146
  hasFittedRef.current = false;
2147
+ setIsVisualizing(false);
2148
  }, [id]);
2149
 
2150
  useEffect(() => {
 
2152
  const timer = setTimeout(() => {
2153
  fitView({ maxZoom: 1.0, padding: 0.1 });
2154
  hasFittedRef.current = true;
2155
+ setIsVisualizing(true);
2156
+ }, 150);
2157
  return () => clearTimeout(timer);
2158
  }
2159
  }, [nodes, fitView]);
 
2773
  <Sidebar />
2774
 
2775
  <main className="flex-grow flex flex-col relative text-primary">
2776
+ {(isLoading || !isVisualizing) && (
2777
  <div className="absolute inset-0 bg-background flex flex-col items-center justify-center z-[60] animate-fade-in">
2778
  <div className="flex flex-col items-center gap-6 p-8 bg-surface-container-lowest border-4 border-primary rounded-3xl shadow-[8px_8px_0px_0px_var(--color-primary)] max-w-sm w-full mx-4 text-center">
2779
  {/* Stylized Neo-brutalist / Sketch spinner */}