App.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 Section16 from "./view/Section16";
  20. import Section17 from "./view/Section17";
  21. import Closing from "./view/Closing";
  22. import { useControls } from "leva";
  23. gsap.registerPlugin(ScrollTrigger);
  24. ScrollTrigger.config({
  25. autoRefreshEvents: "visibilitychange,DOMContentLoaded,load",
  26. // limitCallbacks: true,
  27. });
  28. let resizeTimer = null;
  29. const defaultDebug = localStorage.getItem("debug") === "true" ? true : false;
  30. function App() {
  31. const container = useRef();
  32. const { debug } = useControls({
  33. debug: defaultDebug,
  34. });
  35. const handlerResize = () => {
  36. clearTimeout(resizeTimer);
  37. resizeTimer = setTimeout(function () {
  38. let height = 0.01 * window.innerHeight;
  39. let sHeight = ((16 * window.innerHeight) / 9) * 0.01;
  40. let cHeight = 0;
  41. if (100 * sHeight < window.innerWidth) {
  42. cHeight = 0.5 * (window.innerWidth - 100 * sHeight);
  43. }
  44. document.documentElement.style.setProperty(
  45. "--vh",
  46. "".concat(height, "px")
  47. ),
  48. document.documentElement.style.setProperty(
  49. "--cw",
  50. "".concat(sHeight, "px")
  51. ),
  52. document.documentElement.style.setProperty(
  53. "--cl",
  54. "".concat(cHeight, "px")
  55. );
  56. console.log("fresh");
  57. // ScrollTrigger.refresh();
  58. ScrollTrigger.getAll().forEach((ST) => ST.refresh(true));
  59. }, 100);
  60. };
  61. useEffect(() => {
  62. window.addEventListener("resize", handlerResize, false);
  63. handlerResize();
  64. document.documentElement.style.overflow = "auto";
  65. var vConsole = new window.VConsole();
  66. if (debug) {
  67. vConsole.showSwitch();
  68. } else {
  69. vConsole.hideSwitch();
  70. }
  71. localStorage.setItem("debug", debug);
  72. });
  73. const props = {
  74. // scrollSpeed: scrollSpeed,
  75. debug: debug,
  76. };
  77. return (
  78. <div ref={container}>
  79. <Opening></Opening>
  80. <Section1 {...props} />
  81. <Section2 {...props} />
  82. <Section3 {...props} />
  83. <Section4 {...props} />
  84. <Section5 {...props} />
  85. <Section6 {...props} />
  86. <Section7 {...props} />
  87. <Section8 {...props} />
  88. <Section9 {...props} />
  89. <Section10 {...props} />
  90. <Section11 {...props} />
  91. <Section12 {...props} />
  92. <Section13 {...props} />
  93. <Section14 {...props} />
  94. <Section15 {...props} />
  95. <Section16 {...props} />
  96. <Section17 {...props} />
  97. <Closing {...props} />
  98. </div>
  99. );
  100. }
  101. export default App;