Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate into visibility effect, Issue #9 #12

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,16 @@ p {
color: white;
}

/* .textVideo {
width: 700px;
margin-right: 100px;
position: relative;
left: -230px;
top: 0;
.textVideo {
transform: translateX(-70px);
transition-duration: 2s;
opacity: 0;
}
.contentContainer{
transform: translateX(70px);
transition-duration: 2s;
opacity: 0;
} */
}

.videoContainer {
display: flex;
Expand Down
71 changes: 50 additions & 21 deletions src/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ const Home = () => {
const vdScrollRotateRef = useRef(null);
const contentContainerRef = useRef(null);
const ref = useRef(null);
const midRefTrade = useRef(null);
const midRefWorld = useRef(null);

const isInView = useInView(ref, { once: false });
const isTradeInView = useInView(midRefTrade, { once: false });
const isWorldInView = useInView(midRefWorld, { once: false });
const navigate = useNavigate();

useEffect(() => {
Expand All @@ -32,8 +36,26 @@ const Home = () => {
let lineAppear = document.querySelector(".lineAppear");
lineAppear.style.width = "100%";
lineAppearBottom.style.width = "100%";
const middleLines = document.querySelectorAll(".lineAppearMiddle");
for (let i = 0; i < middleLines.length; i++) {
middleLines[i].style.height = "100%";
}
}
}, [isInView]);
useEffect(() => {
if (isTradeInView) {
const tradeSec = document.querySelector(".textVideo");
tradeSec.style.opacity = "1";
tradeSec.style.transform = "translateX(0px)";
}
}, [isTradeInView]);
useEffect(() => {
if (isWorldInView) {
const worldSec = document.querySelector(".contentContainer");
worldSec.style.opacity = "1";
worldSec.style.transform = "translateX(0px)";
}
}, [isWorldInView]);

return (
<div>
Expand All @@ -59,18 +81,21 @@ const Home = () => {
</div>
<div className="color">
<div className="videoContainer">
<div className="textVideo" ref={textVideoRef}>
<h2 className="trade">TRADE</h2>
<h2 className="tradeAsset">
The virtual destination for digital assets
</h2>
<p>
Buy and sell LAND, Estates, Avatar wearables and names in the
Decentraland Marketplace: stocking the very best digital goods and
paraphernalia backed by the Ethereum blockchain.
</p>
<button className="browse">START BROWSING</button>
</div>
<motion.div ref={midRefTrade} transition={{ duration: 1 }}>
<div className="textVideo" ref={textVideoRef}>
<h2 className="trade">TRADE</h2>
<h2 className="tradeAsset">
The virtual destination for digital assets
</h2>
<p>
Buy and sell LAND, Estates, Avatar wearables and names in the
Decentraland Marketplace: stocking the very best digital goods and
paraphernalia backed by the Ethereum blockchain.
</p>
<button className="browse">START BROWSING</button>
</div>
</motion.div>

<img src={crypto} className="crypto" />
</div>
<div className="scrollRotate">
Expand All @@ -86,17 +111,21 @@ const Home = () => {
></video>
</div>
</div>
<div className="contentContainer" ref={contentContainerRef}>
<h1 className="titleRotate">WORLD</h1>
<p className="linePara">
The XR Portal To The Open Metaverse Enabling You To Play, Learn,
Socialize, Work And Travel To Different Worlds, Making VIVERSE
Even More Immersive From The Second You Put On Your Headset.
</p>
<button className="lineBtn">Explore Now</button>
</div>
<motion.div ref={midRefWorld} transition={{ duration: 1 }}>

<div className="contentContainer" ref={contentContainerRef}>
<h1 className="titleRotate">WORLD</h1>
<p className="linePara">
The XR Portal To The Open Metaverse Enabling You To Play, Learn,
Socialize, Work And Travel To Different Worlds, Making VIVERSE
Even More Immersive From The Second You Put On Your Headset.
</p>
<button className="lineBtn">Explore Now</button>
</div>
</motion.div>
</div>
</div>

<motion.div ref={ref} transition={{ duration: 1 }}>
<div className="lineContainer" id="lineContainer">
<div className="lineAppear " ref={lineAppearRef}></div>
Expand Down