summaryrefslogtreecommitdiffstats
path: root/docusaurus/src/theme/Footer/InputPreloader.tsx
blob: 325f8a71002457c9bd7dc73e70f127c73f33fd1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * @license
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * This file is part of Wolfree.
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 */

import React, { useEffect, useState } from "react";

const InputPreloader = () => {
  const [showIframe, setShowIframe] = useState(false);

  useEffect(() => {
    const handleIframeLoad = () => {
      // Show the iframe after a 3000ms delay
      const timerId = setTimeout(() => setShowIframe(true), 3000);
      // Cleanup the timer when the component unmounts
      return () => clearTimeout(timerId);
    };

    window.scroll(0, 0);

    window.addEventListener("load", handleIframeLoad);

    // Cleanup the event listener when the component unmounts
    return () => window.removeEventListener("load", handleIframeLoad);
  }, []); // Empty dependency array means the effect runs only once after initial render

  return (
    <>
      {/* Use a descriptive title for accessibility */}
      {showIframe && (
        <iframe
          title="Input Page Preloader"
          src="/input/"
          style={{ display: "none" }}
        />
      )}
    </>
  );
};

export default InputPreloader;