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

made animation dependant on last visited page #66 #73

Merged
merged 1 commit into from
May 13, 2024
Merged
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
14 changes: 11 additions & 3 deletions gfdb-frontend/src/pages/education.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,39 @@ import lccLogo from '../resources/images/lcc.jpg'
import concordiaLogo from '../resources/images/concordia.jpg'
import { useSpring, animated as a } from 'react-spring'
import { useEffect, useRef, useState } from 'react'
import { useLocation } from 'react-router-dom'

const Education = () => {

const experienceCardRef = useRef(null)
const [workExpWidth, setWorkExpWidth] = useState()
const location = useLocation()

useEffect(() => {
return () => {
sessionStorage.setItem('lastVisited', location.pathname)
}
}, [location.pathname])

const animationOnRender0 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -1000, opacity: 0},
from: {marginLeft: 1000, opacity: 0},
config: {mass: 1, tension: 150, friction: 30},
...animatedDivStyles
})

const animationOnRender1 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -2000, opacity: 0},
from: {marginLeft: 2000, opacity: 0},
config: {mass: 1, tension: 150, friction: 30},
...animatedDivStyles
})
const animationOnRender2 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -3000, opacity: 0},
from: {marginLeft: 3000, opacity: 0},
config: {mass: 1, tension: 125, friction: 30},
...animatedDivStyles
})
Expand Down
10 changes: 8 additions & 2 deletions gfdb-frontend/src/pages/home/home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useEffect, useState } from 'react'
import { loadImage } from '../../helpers'
import HomeComponent from '../../components/home/home.js'
// import loading from '../../resources/images/whiteG.gif'
import loading from '../../resources/images/whiteG.gif'

import { useLocation } from 'react-router-dom'

const LETTER_PATH = '/letters/'
const LOGO_PATH = '/logos/'
Expand Down Expand Up @@ -33,7 +32,14 @@ const SPRITES = [
const Home = () => {

const [loaded_sprites, setLoadedSprites] = useState()
const location = useLocation()

useEffect(() => {
return () => {
sessionStorage.setItem('lastVisited', location.pathname)
}
}, [location.pathname])

useEffect(() => {
Promise.all(SPRITES.map(url => loadImage(url))).then(
arrayOfImageObjects => {
Expand Down
22 changes: 19 additions & 3 deletions gfdb-frontend/src/pages/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,39 @@ import competeLogo from '../resources/images/compete.svg'
import haivisionLogo from '../resources/images/haivision.jpg'
import { useSpring, animated as a } from 'react-spring'
import { useEffect, useRef, useState } from 'react'
import { useLocation } from 'react-router-dom'

const WorkExperience = () => {

const experienceCardRef = useRef(null)
const [workExpWidth, setWorkExpWidth] = useState()
const location = useLocation()
let directionMultiplier = -1

if (sessionStorage.getItem('lastVisited') === '/')
directionMultiplier = -1

if (sessionStorage.getItem('lastVisited') === '/education')
directionMultiplier = 1

const animationOnRender0 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -1000, opacity: 0},
from: {marginLeft: -1000 * directionMultiplier, opacity: 0},
config: {mass: 1, tension: 150, friction: 30},
...animatedDivStyles
})
const animationOnRender1 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -2000, opacity: 0},
from: {marginLeft: -2000 * directionMultiplier, opacity: 0},
config: {mass: 1, tension: 125, friction: 30},
...animatedDivStyles
})
const animationOnRender2 = useSpring({
opacity: 1,
marginLeft: workExpWidth,
from: {marginLeft: -3000, opacity: 0},
from: {marginLeft: -3000 * directionMultiplier, opacity: 0},
config: {mass: 1, tension: 100, friction: 25},
...animatedDivStyles
})
Expand All @@ -47,6 +56,13 @@ const WorkExperience = () => {
}
}, [])

useEffect(() => {
return () => {
sessionStorage.setItem('lastVisited', location.pathname)
}
}, [location.pathname])


const competeBullets1 = [
'Created Tool Suite to automate parts of our testing process and improve testing efficiency.',
'Created Notifications component to display relevant messages and actions to users.',
Expand Down