|
@@ -1,8 +1,115 @@
|
|
|
-import { Component, createRef } from "react";
|
|
|
-import { gsap, ScrollTrigger } from "gsap/all";
|
|
|
+import { Component, createRef, useRef, useEffect } from "react";
|
|
|
+import gsap from "gsap";
|
|
|
import PropTypes from "prop-types";
|
|
|
import { Action } from "../action";
|
|
|
import { css } from "@emotion/react";
|
|
|
+import styled from "@emotion/styled";
|
|
|
+
|
|
|
+export function ButtonText(props) {
|
|
|
+ const containerRef = useRef();
|
|
|
+ const contentRef = useRef();
|
|
|
+ const ButtonRef = useRef();
|
|
|
+ let isOpen = false;
|
|
|
+ useEffect(() => {
|
|
|
+ gsap.set(contentRef.current, {
|
|
|
+ autoAlpha: 0,
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ const handlerClick = () => {
|
|
|
+ if (!isOpen) {
|
|
|
+ gsap.to(contentRef.current, {
|
|
|
+ autoAlpha: 1,
|
|
|
+ });
|
|
|
+ isOpen = true;
|
|
|
+ ButtonRef.current.classList.add("open");
|
|
|
+ ButtonRef.current.innerText = "x";
|
|
|
+ } else {
|
|
|
+ gsap.to(contentRef.current, {
|
|
|
+ autoAlpha: 0,
|
|
|
+ });
|
|
|
+ isOpen = false;
|
|
|
+ ButtonRef.current.innerText = "+";
|
|
|
+ ButtonRef.current.classList.remove("open");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const Warpper = styled.div`
|
|
|
+ display: flex;
|
|
|
+ position: relative;
|
|
|
+ align-items: center;
|
|
|
+ margin-top: 12px;
|
|
|
+ z-index: 10;
|
|
|
+ `;
|
|
|
+
|
|
|
+ const ButtonWrapper = styled.button`
|
|
|
+ appearance: none;
|
|
|
+ position: relative;
|
|
|
+ font-size: 10px;
|
|
|
+ border: none;
|
|
|
+ margin: 0;
|
|
|
+ align-self: start;
|
|
|
+ outline: none;
|
|
|
+ padding: 0;
|
|
|
+ color: #000;
|
|
|
+ background-color: transparent;
|
|
|
+ height: 20px;
|
|
|
+ width: 20px;
|
|
|
+ min-width: 20px;
|
|
|
+ border-radius: 2px;
|
|
|
+ cursor: pointer;
|
|
|
+ opacity: 1;
|
|
|
+ pointer-events: all;
|
|
|
+ &:before,
|
|
|
+ &:after {
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ background-color: hsla(0, 0%, 100%, 0.8);
|
|
|
+ transition: transform 0.25s ease-out;
|
|
|
+ }
|
|
|
+ &.open {
|
|
|
+ &:before {
|
|
|
+ transform: rotate(90deg);
|
|
|
+ }
|
|
|
+ &:after {
|
|
|
+ transform: rotate(180deg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ &:after {
|
|
|
+ top: 50%;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 4px;
|
|
|
+ margin-top: -2px;
|
|
|
+ }
|
|
|
+ &:before {
|
|
|
+ top: 0;
|
|
|
+ left: 50%;
|
|
|
+ width: 4px;
|
|
|
+ height: 100%;
|
|
|
+ margin-left: -2px;
|
|
|
+ }
|
|
|
+ `;
|
|
|
+
|
|
|
+ const TextWrapper = styled.div`
|
|
|
+ margin-left: 10px;
|
|
|
+ margin-right: 10px;
|
|
|
+ font-size: 12px;
|
|
|
+ `;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Warpper ref={containerRef}>
|
|
|
+ <ButtonWrapper ref={ButtonRef} onClick={handlerClick}>
|
|
|
+ +
|
|
|
+ </ButtonWrapper>
|
|
|
+ <TextWrapper ref={contentRef}>{props.children}</TextWrapper>
|
|
|
+ </Warpper>
|
|
|
+ );
|
|
|
+}
|
|
|
+ButtonText.propTypes = {
|
|
|
+ content: PropTypes.string,
|
|
|
+ children: PropTypes.any,
|
|
|
+};
|
|
|
|
|
|
export function TimeLinePureText(props) {
|
|
|
const progressPosition =
|
|
@@ -30,7 +137,7 @@ export function TimeLinePureText(props) {
|
|
|
}
|
|
|
),
|
|
|
];
|
|
|
- console.log("keyframes-TimeLinePureText", keyframes);
|
|
|
+ // console.log("keyframes-TimeLinePureText", keyframes);
|
|
|
return (
|
|
|
<TimeLineText
|
|
|
trigger={Action.scrubPin}
|
|
@@ -62,7 +169,7 @@ export function TimeLineWallText(props) {
|
|
|
end: progressPosition + duration + fade + fade,
|
|
|
}),
|
|
|
];
|
|
|
- console.log("keyframes-TimeLineWallText", keyframes);
|
|
|
+ // console.log("keyframes-TimeLineWallText", keyframes);
|
|
|
|
|
|
return (
|
|
|
<TimeLineText
|
|
@@ -78,8 +185,13 @@ export function TimeLineWallText(props) {
|
|
|
</TimeLineText>
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
-export class TimeLineText extends Component {
|
|
|
+export function TimeLineTitleText(props) {
|
|
|
+ const verticalOffset = props.verticalOffset || "100vh";
|
|
|
+ return (
|
|
|
+ <TimeLineText verticalOffset={verticalOffset} {...props}></TimeLineText>
|
|
|
+ );
|
|
|
+}
|
|
|
+class TimeLineText extends Component {
|
|
|
constructor(props) {
|
|
|
super();
|
|
|
this.containerRef = createRef();
|
|
@@ -95,6 +207,7 @@ export class TimeLineText extends Component {
|
|
|
this.props = props;
|
|
|
if (props.trigger && props.keyframes) {
|
|
|
var top = props.keyframes[0].start;
|
|
|
+
|
|
|
this.setTop(top);
|
|
|
} else {
|
|
|
if (this.props.progressPosition) {
|
|
@@ -187,7 +300,7 @@ export class TimeLineText extends Component {
|
|
|
}
|
|
|
}
|
|
|
render() {
|
|
|
- const top =
|
|
|
+ const marginTop =
|
|
|
"calc(var(--vh, 1vh) *" + parseFloat(this.props.verticalOffset) + ")";
|
|
|
|
|
|
return (
|
|
@@ -223,7 +336,7 @@ export class TimeLineText extends Component {
|
|
|
<div
|
|
|
className="text-wrapper"
|
|
|
css={css`
|
|
|
- margin-top: ${top};
|
|
|
+ margin-top: ${marginTop};
|
|
|
`}
|
|
|
>
|
|
|
{this.props.children}
|
|
@@ -248,6 +361,9 @@ TimeLineText.defaultProps = {
|
|
|
verticalOffset: "100vh",
|
|
|
};
|
|
|
|
|
|
+TimeLineTitleText.propTypes = {
|
|
|
+ ...TimeLineText.propTypes,
|
|
|
+};
|
|
|
TimeLinePureText.propTypes = {
|
|
|
...TimeLineText.propTypes,
|
|
|
};
|