Skip to content

Commit 62edd72

Browse files
committed
jazz
1 parent d29845b commit 62edd72

9 files changed

Lines changed: 67 additions & 26 deletions

File tree

pages/_includes/index/about.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
>
6666
<a
6767
href="https://en.wikipedia.org/wiki/Bogosort"
68-
class="m-0 border-b-4 border-solid border-transparent font-semibold text-[#00C2FF] transition duration-200 hover:border-[#00C2FF] hover:opacity-60"
68+
class="animate-border-bottom m-0 font-semibold text-[#00C2FF] transition duration-150 after:h-[3px] after:bg-[#00C2FF] after:duration-200 hover:opacity-60 motion-reduce:after:duration-0"
6969
target="_blank"
7070
rel="noreferrer noopener"
7171
>bogosort</a

pages/_includes/index/contact.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section id="contact" class="my-24 px-10 sm:px-20 lg:my-36 2xl:px-32">
1+
<section id="contact" class="mt-24 px-10 pb-16 sm:px-20 lg:mt-36 lg:pb-24 2xl:px-32">
22
<h1 class="group mb-4 w-fit text-4xl font-medium sm:mb-6 sm:text-5xl xl:mb-10 xl:text-7xl">
33
<span class="contact-line-word inline-block opacity-0 motion-reduce:animate-none motion-reduce:opacity-100"
44
>Contact</span
@@ -36,7 +36,7 @@
3636
>
3737
<a
3838
href="https://forms.gle/ThEVfFZfQopvp1929"
39-
class="m-0 border-b-2 border-solid border-transparent font-semibold text-[#00C2FF] transition duration-200 hover:border-[#00C2FF] hover:opacity-60"
39+
class="animate-border-bottom m-0 font-semibold text-[#00C2FF] transition duration-150 after:-bottom-1 after:h-[2px] after:bg-[#00C2FF] after:duration-200 hover:opacity-60 motion-reduce:after:duration-0"
4040
target="_blank"
4141
rel="noreferrer noopener"
4242
>form</a

pages/_includes/index/projects.liquid

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525
{% for project in projects %}
2626
{% assign delay = delay | plus: 50 %}
2727
<a
28-
class="projectCard group flex w-full select-text flex-col items-center rounded-2xl bg-white text-black opacity-0 transition hover:z-10 hover:scale-105 motion-reduce:opacity-100 motion-reduce:hover:scale-100 sm:flex-row animation-delay-[{{ delay }}ms] hover:bg-slate-200 "
28+
class="projectCard group flex w-full select-text flex-col items-center rounded-2xl bg-white text-black opacity-0 transition hover:z-10 hover:scale-105 motion-reduce:opacity-100 motion-reduce:hover:scale-100 sm:flex-row animation-delay-[{{ delay }}ms] hover:bg-slate-300"
2929
draggable="false"
3030
href="{{ project.link }}"
3131
title="{{ project.title }}"
3232
target="_blank"
3333
rel="noreferrer noopener"
3434
>
3535
<div class="flex w-full flex-col items-center p-5 pb-0 sm:flex-row sm:pb-5 sm:pr-0">
36-
<img src="{{ project.image }}" class="max-h-32 w-32 rounded border-2 border-solid border-slate-200">
36+
<img
37+
src="{{ project.image }}"
38+
class="max-h-32 w-32 rounded border-2 border-solid border-slate-200 group-hover:border-slate-300"
39+
>
3740
<div class="projectCardContent mt-2 text-center sm:ml-5 sm:text-left">
3841
<h6 class="text-lg font-medium">{{ project.title }}</h6>
3942
<p class="mt-1 text-sm sm:mt-2 xl:text-base">{{ project.description }}</p>

scripts/section-transitions/about.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export function initTransition() {
3030
}
3131
})
3232

33-
// accouting for large screens, where there is very minimal scrolling
3433
useScrollPosition(({ yPercentage }) => {
35-
if (yPercentage >= 0.99) show()
34+
if (yPercentage >= 0.99) {
35+
show()
36+
}
3637
})
3738
}
3839

scripts/section-transitions/contact.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { useScrollPosition, useYPercentageOnScreen } from "../utils/hooks"
1+
import { usePercentageSeen, useScrollPosition } from "@/utils/hooks"
22

33
const contactSection = document.getElementById("contact")
44
const projectsSection = document.getElementById("projects")
55
const words = [...document.getElementsByClassName("contact-line-word")] as HTMLElement[]
66
const emoji = document.getElementById("contact-line-emoji")
77

8-
const PERCENTAGE_TRIGGER = 0.45
8+
const PERCENTAGE_TRIGGER = 0.9
99

1010
const WORD_ANIMATION = "animate-rise-word"
1111
const EMOJI_ANIMATION = "animate-swoosh"
@@ -16,12 +16,12 @@ export function initTransition() {
1616
// initial
1717
hide()
1818

19-
// relate the position/visibility of previous section to this section
20-
useYPercentageOnScreen(projectsSection, (percentage) => {
19+
// a lil different for last section
20+
usePercentageSeen(contactSection, (percentage) => {
2121
if (percentage >= PERCENTAGE_TRIGGER) {
2222
show()
2323
} else {
24-
const opacity = 1 - (PERCENTAGE_TRIGGER - percentage) / 0.1
24+
const opacity = 1 - (PERCENTAGE_TRIGGER - percentage) / 0.3
2525
contactSection.style.opacity = `${opacity}`
2626
if (opacity <= 0) {
2727
hide()
@@ -31,7 +31,9 @@ export function initTransition() {
3131

3232
// accouting for large screens, where there is very minimal scrolling
3333
useScrollPosition(({ yPercentage }) => {
34-
if (yPercentage >= 0.99) show()
34+
if (yPercentage >= 0.99) {
35+
show()
36+
}
3537
})
3638
}
3739

scripts/section-transitions/navbar.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ export function initTransition() {
3232
}
3333
if (percentage > SETTINGS_TRIGGER) {
3434
settingsBtnOverlay.classList.remove(GROUP_HOVER_CLASS)
35-
settingsBtnOverlayContainer.style.opacity = `${1 - (percentage - SETTINGS_TRIGGER) / 0.1}`
35+
const opacity = 1 - (percentage - SETTINGS_TRIGGER) / 0.1
36+
settingsBtnOverlayContainer.style.opacity = `${opacity}`
37+
if (opacity <= 0) {
38+
settingsBtnOverlayContainer.style.display = "none"
39+
}
3640
} else {
3741
settingsBtnOverlay.classList.add(GROUP_HOVER_CLASS)
3842
settingsBtnOverlayContainer.style.opacity = "1"
43+
settingsBtnOverlayContainer.style.display = "block"
3944
}
4045
})
4146
}

scripts/section-transitions/projects.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// TODO this is basically copy paste from aboutSection
22
// dont repeat urself?
33

4-
import { useScrollPosition, useYPercentageOnScreen } from "../utils/hooks"
4+
import { usePercentageSeen, useScrollPosition, useYPercentageOnScreen } from "../utils/hooks"
55

66
const projectsSection = document.getElementById("projects")
77
const aboutSection = document.getElementById("about")
88
const words = [...document.getElementsByClassName("projects-line-word")] as HTMLElement[]
99
const emoji = document.getElementById("projects-line-emoji")
1010
const projectCards = [...document.getElementsByClassName("projectCard")] as HTMLElement[]
1111

12-
const PERCENTAGE_TRIGGER = 0.6
12+
const PERCENTAGE_TRIGGER = 0.57
1313

1414
const WORD_ANIMATION = "animate-rise-word"
1515
const EMOJI_ANIMATION = "animate-bop"
@@ -35,8 +35,13 @@ export function initTransition() {
3535
})
3636

3737
// accouting for large screens, where there is very minimal scrolling
38+
usePercentageSeen(projectsSection, (percentage) => {
39+
if (percentage >= 0.99) show()
40+
})
3841
useScrollPosition(({ yPercentage }) => {
39-
if (yPercentage >= 0.99) show()
42+
if (yPercentage >= 0.99) {
43+
show()
44+
}
4045
})
4146
}
4247

scripts/utils/hooks.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ export function usePercentageSeen(element: HTMLElement | null, onChange: (percen
3232
const overTopEdge = elementOffsetTop < topEdge
3333

3434
// calculate the percentage on screen
35-
// NOTE could divide by min(elementHeight, viewportHeight) instead.
35+
// NOTE we divide by min(elementHeight, viewportHeight).
3636
// That way, if element is larger than screen, will return 100% when element covers entire screen
3737
const calcPercentage =
38-
(overTopEdge ? elementOffsetTop + elementHeight - topEdge : bottomEdge - elementOffsetTop) / elementHeight
38+
(overTopEdge ? elementOffsetTop + elementHeight - topEdge : bottomEdge - elementOffsetTop) /
39+
Math.min(elementHeight, viewportHeight)
3940
// Restrict the range to between 0 and 1
40-
const percentage = Math.round(clampValue(0, 1, calcPercentage) * 100) / 100
41+
const percentage = clampValue(0, 1, calcPercentage)
42+
4143
onChange(percentage)
4244
})
4345

@@ -67,7 +69,7 @@ export function useYPercentageOnScreen(
6769
const trigger = elementPos - viewportHeight
6870
// now calculate the element's position y on screen, and get percentage y
6971
// also restrict range to between 0 and 1
70-
const percentage = Math.round(clampValue(0, 1, (scrollPos - trigger) / viewportHeight) * 100) / 100
72+
const percentage = clampValue(0, 1, (scrollPos - trigger) / viewportHeight)
7173
onChange(percentage)
7274
})
7375

@@ -80,11 +82,8 @@ export function useScrollPosition(onChange: ({ yPos, yPercentage }: { yPos: numb
8082
scrollHooks.push(() => {
8183
const yPos = window.scrollY
8284
const yPercentage =
83-
Math.round(
84-
(document.documentElement.scrollTop /
85-
(document.documentElement.scrollHeight - document.documentElement.clientHeight)) *
86-
100
87-
) / 100
85+
document.documentElement.scrollTop /
86+
(document.documentElement.scrollHeight - document.documentElement.clientHeight)
8887
onChange({ yPos, yPercentage })
8988
})
9089

styles/index.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,29 @@
5050

5151
/* #endregion font */
5252
}
53+
54+
@layer utilities {
55+
.animate-border-bottom {
56+
position: relative;
57+
}
58+
59+
.animate-border-bottom:after {
60+
content: "";
61+
position: absolute;
62+
left: 0;
63+
/* spacing in bottom */
64+
bottom: -4px;
65+
/* border thickness */
66+
height: 2px;
67+
width: 100%;
68+
transform-origin: left center;
69+
background: white;
70+
transform: scale3d(0, 1, 1);
71+
transition: transform 500ms cubic-bezier(0.86, 0, 0.07, 1);
72+
border-radius: 4px;
73+
}
74+
75+
.animate-border-bottom:hover:after {
76+
transform: scale3d(1, 1, 1);
77+
}
78+
}

0 commit comments

Comments
 (0)