App.jsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { useRef, useEffect } from "react";
  2. import { gsap, ScrollTrigger } from "gsap/all";
  3. import Opening from "./components/Opening";
  4. import Section1 from "./view/Section1";
  5. import Section2 from "./view/Section2";
  6. import Section3 from "./view/Section3";
  7. import Section4 from "./view/Section4";
  8. import Section5 from "./view/Section5";
  9. import Section6 from "./view/Section6";
  10. import Section7 from "./view/Section6";
  11. import Section8 from "./view/Section8";
  12. import Section9 from "./view/Section9";
  13. import Section10 from "./view/Section10";
  14. import Section11 from "./view/Section11";
  15. import Section12 from "./view/Section12";
  16. import Section13 from "./view/Section13";
  17. import Section14 from "./view/Section14";
  18. import Section15 from "./view/Section15";
  19. import { useControls } from "leva";
  20. gsap.registerPlugin(ScrollTrigger);
  21. ScrollTrigger.config({
  22. autoRefreshEvents: "visibilitychange,DOMContentLoaded,load",
  23. // limitCallbacks: true,
  24. });
  25. let resizeTimer = null;
  26. function App() {
  27. const container = useRef();
  28. const { debug } = useControls({ debug: false });
  29. const handlerResize = () => {
  30. clearTimeout(resizeTimer);
  31. resizeTimer = setTimeout(function () {
  32. let height = 0.01 * window.innerHeight;
  33. let sHeight = ((16 * window.innerHeight) / 9) * 0.01;
  34. let cHeight = 0;
  35. if (100 * sHeight < window.innerWidth) {
  36. cHeight = 0.5 * (window.innerWidth - 100 * sHeight);
  37. }
  38. document.documentElement.style.setProperty(
  39. "--vh",
  40. "".concat(height, "px")
  41. ),
  42. document.documentElement.style.setProperty(
  43. "--cw",
  44. "".concat(sHeight, "px")
  45. ),
  46. document.documentElement.style.setProperty(
  47. "--cl",
  48. "".concat(cHeight, "px")
  49. );
  50. console.log("fresh");
  51. // ScrollTrigger.refresh();
  52. ScrollTrigger.getAll().forEach((ST) => ST.refresh(true));
  53. }, 100);
  54. };
  55. useEffect(() => {
  56. window.addEventListener("resize", handlerResize, false);
  57. handlerResize();
  58. document.documentElement.style.overflow = "auto";
  59. });
  60. return (
  61. <div ref={container}>
  62. <Opening></Opening>
  63. <Section1 debug={debug} />
  64. <Section2 debug={debug} />
  65. <Section3 debug={debug} />
  66. <Section4 debug={debug} />
  67. <Section5 debug={debug} />
  68. <Section6 debug={debug} />
  69. <Section7 debug={debug} />
  70. <Section8 debug={debug} />
  71. <Section9 debug={debug} />
  72. <Section10 debug={debug} />
  73. <Section11 debug={debug} />
  74. <Section12 debug={debug} />
  75. <Section13 debug={debug} />
  76. <Section14 debug={debug} />
  77. <Section15 debug={debug} />
  78. </div>
  79. );
  80. }
  81. export default App;