From 62ffeaed2dbb8491f5be2f1805cc97a4fb229a6f Mon Sep 17 00:00:00 2001 From: Camerin Figueroa Date: Wed, 12 Jan 2022 20:39:00 -0500 Subject: [PATCH] Improved Intro Performance --- src/components/Intro.js | 45 ++++++++++++--------------- src/components/css/Intro.css | 26 ++++++++++------ src/components/subcomponents/Topic.js | 8 ++--- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/components/Intro.js b/src/components/Intro.js index a9d9698..214a9f7 100644 --- a/src/components/Intro.js +++ b/src/components/Intro.js @@ -47,11 +47,10 @@ class Intro extends React.Component { // Activate animation going to next topic this.setState({ - prev: 'current', - curr: 'next', + prev: 'current top', }); - // Wait 500 ms until the transition is finished + // Wait 900 ms until the transition is finished setTimeout(()=>{ // Once timeout finishes, place topics in correct location without transition let prevloc = this.state.prevLoc-1; @@ -59,51 +58,47 @@ class Intro extends React.Component { let nextloc = this.state.nextLoc-1; this.setState({ prev: 'previous notrans', - curr: 'current notrans', - prevLoc: prevloc, // Move correct topics into necessary divs currLoc: currloc, nextLoc: nextloc, }); - // wait another 20 ms to + // wait another 75 ms to setTimeout(()=>{ - this.setState({ // remove notrans from each div - prev: 'previous', - curr: 'current', - }); + this.setState({ // remove notrans from each div + prev: 'previous', + prevLoc: prevloc, + }); - }, 20); + }, 75); - }, 500); + }, 900); } else if (input === "down" && this.state.nextLoc < this.topics.length) { // Activate transition going to previous topic this.setState({ - curr: 'previous', + //curr: 'previous', next: 'current' }); - // wait 500 ms before placing all topics into correct divs + // wait 900 ms before placing all topics into correct divs setTimeout(()=>{ // move all topics into correct divs let prevloc = this.state.prevLoc+1; let currloc = this.state.currLoc+1; let nextloc = this.state.nextLoc+1; this.setState({ - curr: 'current notrans', next: 'next notrans', - prevLoc: prevloc, // Move correct topics into necessary divs + prevLoc: prevloc, currLoc: currloc, - nextLoc: nextloc, }); // wait 20ms and remove notrans setTimeout(()=>{ - this.setState({ - curr: 'current', - next: 'next', - }); - }, 20); - }, 500); + this.setState({ + next: 'next', + nextLoc: nextloc, + }); + }, 75); + }, 900); } else if (input === "down" && this.state.nextLoc >= this.topics.length) { // Set something to happen when you reach the end @@ -137,8 +132,8 @@ class Intro extends React.Component { View a list of projects I've done right on this website. You can easily direct to github where you can see the project code itself. , - - Explore Cam's Projects + + Read through some homemade articles that go over interesting topics and may teach you some skills in tech. ]; diff --git a/src/components/css/Intro.css b/src/components/css/Intro.css index 8ad1497..52fd752 100644 --- a/src/components/css/Intro.css +++ b/src/components/css/Intro.css @@ -14,13 +14,14 @@ } .intro .previous { - opacity: 0; - height:0; + z-index:11; + opacity: 0.01; + height:100%; width:100vw; display: flex; position:fixed; - transition: opacity 500ms ease-out, height 500ms ease-out, top 500ms ease-out; - top:0; + transition: opacity 750ms ease-out, top 750ms ease-out; + top:-99%; left:0; justify-content: center; align-items: center; @@ -33,7 +34,7 @@ width:100vw; display: flex; position:fixed; - transition: opacity 500ms ease-in, height 500ms ease-in, top 500ms ease-in; + transition: opacity 750ms ease-out, top 750ms ease-out; top:0; left:0; justify-content: center; @@ -41,18 +42,23 @@ } .intro .next { - opacity: 0; - height:0; + z-index: 11; + opacity: 0.01; + height:100%; width:100vw; display: flex; position:fixed; - transition: opacity 500ms ease-out, height 500ms ease-out, top 500ms ease-out; - top:100%; + transition: opacity 750ms ease-out, top 750ms ease-out; + top:99%; left:0; justify-content: center; align-items: center; } +.intro .top { + z-index: 11 !important; +} + .notrans { transition: none !important; } @@ -76,7 +82,7 @@ } .intro .navbutton { - z-index: 12; + z-index: 14; font-size: 48px; width: 100%; top:0; diff --git a/src/components/subcomponents/Topic.js b/src/components/subcomponents/Topic.js index 926242a..d53f3f6 100644 --- a/src/components/subcomponents/Topic.js +++ b/src/components/subcomponents/Topic.js @@ -1,5 +1,6 @@ import React from 'react'; import '../css/Topic.css'; +import { Link } from 'react-router-dom'; const Card = (props) => { /** @@ -13,18 +14,17 @@ const Card = (props) => { */ return ( -
-

{props.title}

+

{props.title}

{props.children}
-
+ ); };