%PDF- %PDF-
Mini Shell

Mini Shell

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

import { useEffect, useRef } from "react";
import Image from "next/image";
import parse from "html-react-parser";

import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

//bg
import { AboutBg } from "./Backgrounds";
// import { useInView } from "./useInView";
// import { useGlobalContext } from "./store/context/GlobalContext";

gsap.registerPlugin(ScrollTrigger);

function About({ data }) {
  // const targetColorRef = useRef(null);
  // const useTarget = useInView(targetColorRef, { threshold: 0.1 });
  // const { setIsColor } = useGlobalContext();

  // useEffect(() => {
  //   if (useTarget) {
  //     setIsColor("white");
  //   } else {
  //     setIsColor("original");
  //   }
  // }, [useTarget]);

  useEffect(() => {
    let aboutWrapper = document.querySelector("#intro");
    gsap.timeline({
      scrollTrigger: {
        trigger: ".mainAbout",
        start: "-25% top",
        onEnter: () => aboutWrapper.classList.add("revealed"),
        onLeave: () => aboutWrapper.classList.remove("revealed"),
        onEnterBack: () => aboutWrapper.classList.add("revealed"),
        onLeaveBack: () => aboutWrapper.classList.remove("revealed"),
      },
    });

    let width = screen.width;

    gsap.to(width < 768 ? "[data-mobile-speed]" : "[data-speed]", {
      y: (i, el) =>
        (1 -
          parseFloat(
            el.getAttribute(width < 768 ? "data-mobile-speed" : "data-speed")
          )) *
        ScrollTrigger.maxScroll(window),
      ease: "none",
      scrollTrigger: {
        start: width < 768 ? "15%" : "20%",
        end: "max",
        invalidateOnRefresh: true,
        scrub: 0,
      },
    });
  }, []);
  return (
    <div className="mainAbout orange" id="aboutScroll">
      <div className="intro" id="intro">
        <div id="about" className="text">
          <div className="adventureDiv">
            <h4>{data.small_title_adv}</h4>
          </div>
          <h1>{parse(data.title_adv)}</h1>
          <p>{parse(data.description_adv)}</p>
        </div>
        <div className="images">
          <Image
            src={`${data.right_image}`}
            width={535}
            height={690}
            layout="responsive"
            alt=""
          />
        </div>
      </div>
      <div className="aboutBackground">
        <AboutBg />
      </div>
      <div className="lowerIntro">
        <div className="title">
          <h1>{parse(data.second_title_adv)}</h1>
        </div>
        <div className="text">
          <p>{parse(data.second_description_adv)}</p>
        </div>
      </div>

      <div className="dubrovnik">
        <div className="dubrovnikBackground">
          <h1 className="sticky-title">{data.title_gallery}</h1>
        </div>
        <div className="collage col1">
          <div data-mobile-speed="1.5" data-speed="2" className="image">
            <Image
              src={`${data.gallery[0]}`}
              alt=""
              width={554}
              height={482}
              layout="responsive"
            />
          </div>
          <div data-mobile-speed="1.5" data-speed="1.25" className="image">
            <Image
              src={`${data.gallery[1]}`}
              alt=""
              width={554}
              height={482}
              layout="responsive"
            />
          </div>
        </div>

        <div className="collage col2">
          <div data-mobile-speed="1.5" data-speed="1.5" className="image">
            <Image
              src={`${data.gallery[2]}`}
              alt=""
              width={554}
              height={482}
              layout="responsive"
            />
          </div>
          <div data-mobile-speed="1.5" data-speed="1.5" className="image">
            <Image
              src={`${data.gallery[3]}`}
              alt=""
              width={554}
              height={482}
              layout="responsive"
            />
          </div>
        </div>
      </div>
    </div>
  );
}

export default About;

Zerion Mini Shell 1.0