<template>
  <div class="whitepaper">
    <div
      class="whitepaper-title"
      ref="mTab"
      id="bgTest"
      :style="{ transform: 'translateY(' + -positionY1 + 'px)' }"
    >
      Whitepaper
    </div>
    <div class="whitepaper-bg">
      <img src="@/assets/img/about/whitepaper-bg.png" alt="" />
    </div>
    <div class="whitepaper-bottom-boder">
      <img src="@/assets/img/about/whitepaper-bottom-boder.png" alt="" />
    </div>
    <div class="content">
      <div class="content-left" ref="contentLeft">
        <div class="whitepaper-moster">
          <img src="../../assets/img/about/whitepaper-moster.png" alt="" />
        </div>
      </div>
      <div class="content-right">
        <div class="title">Whitepaper</div>
        <div class="title-boder">
          <img src="@/assets/img/about/whitepaper-title-boder.png" alt="" />
        </div>
        <div class="slogan">
          <div>
            <!-- <ScrollAnimatedText>
              CEBG is the first blockchain-based animation game which consists
              of Moba, Battleroyal; funded by more than 7 institutional
              investors.
            </ScrollAnimatedText> -->
          </div>
        </div>
        <div class="more">
          <a href="https://contact-63.gitbook.io/cebg-whitepaper/">
            Learn more about our studio mission
            <span class="more-right">>></span></a
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, reactive, onMounted } from "vue";
import ScrollAnimatedText from "../global/ScrollAnimatedText.vue";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";

gsap.registerPlugin(ScrollTrigger);
const Y1 = ref(0);
const ratio = ref(0.2); //视差偏移率
const positionY1 = ref(0); //背景Y轴偏移量
const contentLeft = ref(null);
const animationTriggered = ref(false);
onMounted(() => {
  window.addEventListener("scroll", handleScroll); //创建滚动监听，页面滚动回调handleScroll方法
  let bgTest = document.getElementById("bgTest");
  Y1.value = bgTest.offsetTop * ratio.value;
  // contentLeftAnimation();
  contentLeftAnimation();
});
function contentLeftAnimation() {
  gsap.from(contentLeft.value, {
    x: -1000,
    duration: 1,
    ease: "power2.out",
  });
}
function isContentLeftVisible() {
  const rect = contentLeft.value.getBoundingClientRect();
  const windowHeight =
    window.innerHeight || document.documentElement.clientHeight;
  return rect.top <= windowHeight && rect.bottom >= 0;
}
function handleScroll() {
  if (!animationTriggered.value && isContentLeftVisible()) {
    contentLeftAnimation();
    animationTriggered.value = true;
  }
  const scrollTop =
    window.pageYOffset ||
    document.documentElement.scrollTop ||
    document.body.scrollTop;
  positionY1.value = Y1.value - scrollTop * ratio.value; //原始高度-滚动距离*视差系数
}
</script>

<style lang="scss" scoped>
.whitepaper {
  position: relative;
  // padding-top: 100px;
  padding-bottom: 167px;
  .whitepaper-title {
    position: absolute;
    left: 3%;
    top: -400px;
    font-size: 220px;
    font-family: "Big John";
    font-weight: 400;
    font-style: italic;
    color: #272727;
    // opacity: 0.3;
    z-index: -1;
  }
  .whitepaper-bg {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: -10;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  .whitepaper-bottom-boder {
    position: absolute;
    left: 0;
    bottom: 0px;
    right: 0;
    width: 100%;
    height: 95px;
    z-index: -10;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .content {
    width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items:center;
    .whitepaper-moster {
      padding-left: 150px;
    }
    .title {
      font-size: 48px;
      margin-left: 33px;
      font-family: "Big John";
      font-weight: 400;
      color: #ffffff;
    }
    .title-boder {
      padding-top: 20px;
      width: 707px;
      height: 71px;
    }
    .slogan {
      // width: 590px;
      // margin-top: 54px;
      // margin-left: 64px;
      // padding-bottom: 52px;
      // font-size: 18px;
      // font-family: "Poppins";
      // font-weight: 400;
      // color: #ffffff;
      // line-height: 26px;
    }
    .more {
      border: 2px solid #cfa944;
      color: #cfa944;
      width: 546px;
      text-align: center;
      height: 61px;
      line-height: 61px;
      margin-left: 24px;
      font-size: 26px;
      font-family: Arial;
      font-weight: bold;
      a {
        color: #cfa944;
      }
    }
    .more-right {
      color: #cfa944;
    }
  }
}
</style>
