-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from harry-whorlow/second-section
Second section
- Loading branch information
Showing
11 changed files
with
494 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<div id="estd-container" class="flex-column-center"> | ||
<div class="flex-row estd-row-center"> | ||
<p class="estd-p estd-label">M </p> | ||
|
||
<div id="estd-minuets-container" class="estd-row"> | ||
<p class="minuets estd-p estd-split-text"></p> | ||
</div> | ||
</div> | ||
|
||
<div class="flex-row"> | ||
<p class="estd-p estd-label">H </p> | ||
|
||
<div id="estd-hours-container" class="estd-row"> | ||
<p class="hours estd-p estd-split-text"></p> | ||
</div> | ||
</div> | ||
|
||
<div class="flex-row"> | ||
<p class="estd-p estd-label">D </p> | ||
|
||
<div id="estd-days-container" class="estd-row"> | ||
<p class="days estd-p estd-split-text"></p> | ||
</div> | ||
</div> | ||
|
||
<div class="flex-row"> | ||
<p class="estd-p">COUNTED</p> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
#estd-container { | ||
position: fixed; | ||
|
||
bottom: 10px; | ||
left: 10px; | ||
|
||
z-index: 51; | ||
mix-blend-mode: difference; | ||
|
||
opacity: 0; | ||
} | ||
|
||
.estd-row { | ||
width: 100%; | ||
position: relative; | ||
|
||
overflow: hidden; | ||
} | ||
|
||
.estd-label { | ||
min-width: 18px; | ||
} | ||
</style> | ||
|
||
<style is:global> | ||
.estd-p { | ||
font-family: neuemachina; | ||
color: #c0c0c0; | ||
|
||
display: inline-block; | ||
} | ||
|
||
.estd-split-text { | ||
position: absolute; | ||
left: 0; | ||
} | ||
|
||
.estd-hidden { | ||
top: 20px; | ||
} | ||
</style> | ||
|
||
<script> | ||
import gsap from 'gsap'; | ||
import { SplitText } from 'gsap/all'; | ||
gsap.registerPlugin(SplitText); | ||
|
||
import { returnEstd } from './utils/getDateValues'; | ||
|
||
gsap.to('#estd-container', { delay: 5, opacity: 1, duration: 0.5 }); | ||
|
||
const { minuets, hours, days } = returnEstd(); | ||
(document.querySelector('.minuets') as Element).innerHTML = minuets; | ||
(document.querySelector('.hours') as Element).innerHTML = hours; | ||
(document.querySelector('.days') as Element).innerHTML = days; | ||
|
||
const targetdata = { | ||
minuets: { value: minuets, container: document.querySelector('#estd-minuets-container') }, | ||
hours: { value: hours, container: document.querySelector('#estd-hours-container') }, | ||
days: { value: days, container: document.querySelector('#estd-days-container') }, | ||
}; | ||
|
||
const animateTime = () => { | ||
const currentTime = returnEstd(); | ||
|
||
(Object.keys(currentTime) as Array<keyof typeof currentTime>).forEach((timeRange) => { | ||
if (currentTime[timeRange] != targetdata[timeRange].value) { | ||
const pNode = document.createElement('p'); | ||
pNode.classList.add(timeRange); | ||
pNode.classList.add('estd-hidden'); | ||
pNode.classList.add('estd-split-text'); | ||
pNode.classList.add('estd-p'); | ||
|
||
const pNodeText = document.createTextNode(currentTime[timeRange]); | ||
pNode.appendChild(pNodeText); | ||
targetdata[timeRange].container?.appendChild(pNode); | ||
|
||
const cleanUp = () => { | ||
targetdata[timeRange].value = currentTime[timeRange]; | ||
document.querySelectorAll(`.${timeRange}`)[0].remove(); | ||
}; | ||
|
||
gsap | ||
.timeline() | ||
.to( | ||
new SplitText(document.querySelectorAll(`.${timeRange}`)[0], { type: 'chars' }).chars, | ||
{ | ||
duration: 0.5, | ||
y: -20, | ||
stagger: 0.2, | ||
}, | ||
0 | ||
) | ||
.to( | ||
new SplitText(document.querySelectorAll(`.${timeRange}`)[1], { type: 'chars' }).chars, | ||
{ | ||
duration: 0.5, | ||
y: -20, | ||
stagger: 0.2, | ||
onComplete: () => cleanUp(), | ||
}, | ||
0.5 | ||
); | ||
} | ||
}); | ||
}; | ||
|
||
setTimeout( | ||
() => { | ||
animateTime(); | ||
setInterval(animateTime, 60000); | ||
}, | ||
(60 - new Date().getSeconds()) * 1000 | ||
); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import dayjs from 'dayjs'; | ||
|
||
const birthDate = dayjs('02/28/1998'); | ||
|
||
export const returnEstd = (): { days: string; hours: string; minuets: string } => { | ||
const curentDate = dayjs(); | ||
const dateDifferancSec = curentDate.diff(birthDate, 's'); | ||
|
||
const days = Math.floor(dateDifferancSec / 86400); | ||
const hours = Math.floor((dateDifferancSec - days * 86400) / 3600); | ||
const minuets = Math.floor((dateDifferancSec - days * 86400 - hours * 3600) / 60); | ||
|
||
return { | ||
days: String(days), | ||
hours: hours.toLocaleString(undefined, { minimumIntegerDigits: 2 }), | ||
minuets: minuets.toLocaleString(undefined, { minimumIntegerDigits: 2 }), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<div> | ||
<div class="rail" id="big"> | ||
<h1 class="big-text">PART TIME DEVELOPER</h1> | ||
<h1 class="big-text">&</h1> | ||
<h1 class="big-text">FULL TIME PROCRASTINATOR</h1> | ||
<h1 class="big-text">-</h1> | ||
<h1 class="big-text">OCCASIONALLY PRESENT</h1> | ||
<h1 class="big-text">//  </h1> | ||
</div> | ||
|
||
<div class="rail" id="small"> | ||
<h1 class="small-text">Python</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">JavaScript</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">Go Lang</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">TypeScript</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">Python</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">JavaScript</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">Go Lang</h1> | ||
<h1 class="small-text">-</h1> | ||
<h1 class="small-text">TypeScript</h1> | ||
<h1 class="small-text">-  </h1> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.big-text { | ||
font-size: 100px; | ||
font-weight: 400; | ||
} | ||
|
||
.small-text { | ||
font-size: 40px; | ||
font-weight: 400; | ||
} | ||
|
||
h1 { | ||
font-family: neuemachina; | ||
|
||
white-space: nowrap; | ||
|
||
letter-spacing: ls(120); | ||
line-height: 1em; | ||
|
||
margin-right: 2.5rem; | ||
|
||
color: var(--main-text-light); | ||
|
||
z-index: 100; | ||
} | ||
|
||
.rail { | ||
display: flex; | ||
} | ||
</style> | ||
|
||
<script> | ||
import gsap from 'gsap'; | ||
import ScrollTrigger from 'gsap/ScrollTrigger'; | ||
gsap.registerPlugin(ScrollTrigger); | ||
|
||
import { horizontalLoop } from '../../utils/textScrollerHelpers'; | ||
|
||
const scrollingText = gsap.utils.toArray('#big .big-text'); | ||
const smallScrollingText = gsap.utils.toArray('#small .small-text'); | ||
|
||
// big timeline | ||
const BigTl = horizontalLoop(scrollingText, { | ||
paused: true, | ||
repeat: -1, | ||
speed: 0.5, | ||
}); | ||
|
||
let bigDirection = 1; | ||
let BigT: GSAPTween; | ||
|
||
ScrollTrigger.create({ | ||
trigger: '#overlay-secondary', | ||
start: 'top top', | ||
end: 'bottom top', | ||
onUpdate: (self) => { | ||
if (self.direction !== bigDirection) { | ||
bigDirection = self.direction; | ||
BigT && BigT.kill(); | ||
BigT = gsap.to(BigTl, { | ||
duration: 0.3, | ||
timeScale: self.direction, | ||
}); | ||
} | ||
}, | ||
}); | ||
|
||
ScrollTrigger.create({ | ||
trigger: '.second-section', | ||
start: 'top center', | ||
end: 'bottom bottom', | ||
onEnter: () => BigTl.play(), | ||
onLeave: () => BigTl.paused(), | ||
}); | ||
|
||
//small timeline | ||
const smallTl = horizontalLoop(smallScrollingText, { | ||
repeat: -1, | ||
speed: 1, | ||
reversed: true, | ||
}); | ||
|
||
let smallDirection = -1; | ||
let smallT: GSAPTween; | ||
|
||
ScrollTrigger.create({ | ||
trigger: '#overlay-secondary', | ||
start: 'top top', | ||
end: 'bottom top', | ||
onUpdate: (self) => { | ||
if (self.direction !== smallDirection) { | ||
smallDirection = self.direction; | ||
smallT && smallT.kill(); | ||
smallT = gsap.to(smallTl, { | ||
duration: 0.3, | ||
timeScale: self.direction * -1, | ||
}); | ||
} | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.