%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/src/Components/
Upload File :
Create Path :
Current File : //var/www/html/src/Components/HeroLogo.js

import { useEffect, useState } from "react";
import Menu from "./Menu";

import Link from "next/link";

import { gsap, Power3 } from "gsap";
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";
import { Logo, LogoWhite, LogoFullWhite, BookSvg } from "./Icons";
// import { useGlobalContext } from "./store/context/GlobalContext";

gsap.registerPlugin(ScrollTrigger);

function HeroLogo() {
  const [isActive, setIsActive] = useState(false);
  const [logoColor, setLogoColor] = useState("original");
  const [menuColor, setMenuColor] = useState("black");
  // const { isColor } = useGlobalContext();

  const hideScroll = () => {
    let html = document.querySelector("html");
    html.classList.add("overflowHidden");
  };

  const openMenu = () => {
    const slideIn = gsap.timeline();
    slideIn.to(".mainMenu", { x: 0, ease: Power3.easeOut, duration: 1 });
  };

  const closeMenu = () => {
    const slideOut = gsap.timeline({
      onComplete: () => setIsActive(false),
      overwrite: true,
    });
    slideOut.to(".mainMenu", { x: "100%", ease: Power3.easeOut });
  };

  useEffect(() => {
    ScrollTrigger.matchMedia({
      "(min-width: 1024px)": function () {
        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainAbout",
            start: "top-=700",
            end: "bottom-=100",
            onEnter: () => {
              setLogoColor("white");
            },
            onLeave: () => {
              setLogoColor("original");
            },
            onEnterBack: () => {
              setLogoColor("white");
            },
            onLeaveBack: () => {
              setLogoColor("original");
            },
          },
        });
        gsap.timeline({
          scrollTrigger: {
            trigger: ".bookNow > .animate",
            start: "top",
            onEnter: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeave: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onEnterBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeaveBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
          },
        });
        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainRent",
            start: "top-=100",
            end: "bottom-=80",
            onEnter: () => {
              setLogoColor("fullWhite");
              setMenuColor("orange");
            },
            onLeave: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onEnterBack: () => {
              setLogoColor("fullWhite");
              setMenuColor("orange");
            },
            onLeaveBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
          },
        });

        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainTourDetails",
            start: "top",
            onEnter: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeave: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onEnterBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeaveBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
          },
        });

        // gsap.timeline({
        //   scrollTrigger: {
        //     trigger: ".videoPlayer",
        //     start: "top",
        //     onEnter: () => {
        //       setLogoColor("fullWhite");
        //       setMenuColor("orange");
        //     },
        //     onLeave: () => {
        //       setLogoColor("white");
        //       setMenuColor("black");
        //     },
        //     onEnterBack: () => {
        //       setLogoColor("fullWhite");
        //       setMenuColor("orange");
        //     },
        //     onLeaveBack: () => {
        //       setLogoColor("white");
        //       setMenuColor("black");
        //     },
        //   },
        // });
        // let mainTourTween = gsap.timeline({
        //   scrollTrigger: {
        //     trigger: ".mainTour",
        //     start: "top",
        //     end: "bottom",
        //     onEnter: () => setLogoColor("original"),
        //     onLeave: () => setLogoColor("fullWhite"),
        //     onEnterBack: () => setLogoColor("original"),
        //     onLeaveBack: () => setLogoColor("fullWhite"),
        //   },
        // });

        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainContact",
            start: "top+=600",
            onEnter: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeave: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onEnterBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeaveBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
          },
        });

        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainNewsDetails > .content",
            start: "top-=200",
            onEnter: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeave: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onEnterBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
            onLeaveBack: () => {
              setLogoColor("original");
              setMenuColor("black");
            },
          },
        });

        gsap.timeline({
          scrollTrigger: {
            trigger: ".mainNewsFeed",
            start: "top",
            onEnter: () => {
              setLogoColor("original");
            },
            onLeave: () => {
              setLogoColor("original");
            },
            onEnterBack: () => {
              setLogoColor("original");
            },
            onLeaveBack: () => {
              setLogoColor("original");
            },
          },
        });
      },
    });
  }, []);

  return (
    <div className="heroLogo">
      <div className="logo">
        <Link href="/">
          <a>
            {logoColor === "original" ? (
              <Logo />
            ) : logoColor === "white" ? (
              <LogoWhite />
            ) : logoColor === "fullWhite" ? (
              <LogoFullWhite />
            ) : (
              <Logo />
            )}
          </a>
        </Link>
        <div
          className="book"
          onClick={() => {
            setIsActive(true);
            openMenu();
            hideScroll();
          }}
        >
          <span className={menuColor}>Menu</span>
          <div className="bookSvg">
            <BookSvg />
          </div>
        </div>
        <div
          className="menu"
          style={{
            display: isActive ? "block" : "none",
          }}
        >
          <Menu closeMenu={closeMenu} />
        </div>
      </div>
    </div>
  );
}

export default HeroLogo;

Zerion Mini Shell 1.0