Skip to content

Commit cae01f4

Browse files
committed
New header animation effect
1 parent d22457e commit cae01f4

File tree

3 files changed

+50
-14
lines changed

3 files changed

+50
-14
lines changed

css/style.scss

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ body {
7373
}
7474

7575
.card {
76-
background: black;
76+
background: rgba(0,0,0,0.5);
7777
//border-color: white;
7878
}
7979

@@ -275,6 +275,7 @@ span.hu {
275275
border-radius: 1em;
276276
border: 2px solid #aaa;
277277
box-shadow: 0px 0.3em 0.6em rgba(0,0,0,0.1);
278+
overflow: clip;
278279
h2 {
279280
/* L shaped border
280281
border-image: linear-gradient(to right, #1ec1c7, #4e44b0) 1 100%;
@@ -287,8 +288,24 @@ span.hu {
287288
//border-width: 0 0 0 5px;
288289
text-align: left;
289290
//padding: 5px 15px;
291+
top: 0px;
292+
margin-left: 0px;
290293
font-weight: 900;
291294
margin-bottom: 0.3em;
295+
transform-origin: top left;
296+
297+
&.stickyheader {
298+
display: inline-block;
299+
transition: 0.5s $bezier;
300+
}
301+
302+
&.sticky {
303+
z-index: -1;
304+
position: sticky;
305+
top: 2rem;
306+
transform: scale(10);
307+
opacity: 0.2;
308+
}
292309
}
293310
}
294311

@@ -693,14 +710,20 @@ div.shake {
693710
h3 {
694711
font-size: 2em;
695712
}
696-
&.arrow h3:after {
697-
content: ">";
698-
opacity: 0.3;
699-
margin-left: 0.1em;
700-
transition: 0.3s;
701-
}
702-
@include hover {
703-
&.arrow:hover h3:after {
713+
&.arrow {
714+
h3:after {
715+
content: ">";
716+
opacity: 0.3;
717+
margin-left: 0.1em;
718+
transition: 0.3s;
719+
}
720+
@include hover {
721+
&:hover h3:after {
722+
opacity: 0.6;
723+
margin-left: 0.4em;
724+
}
725+
}
726+
&:active h3:after {
704727
opacity: 0.6;
705728
margin-left: 0.4em;
706729
}
@@ -733,6 +756,7 @@ div.shake {
733756
box-shadow: 0px 0.3em 0.6em rgba(0,0,0,0.15);
734757
margin-bottom: 1.25em !important;
735758
font-size: 0.8rem;
759+
background: rgba(255,255,255,0.5);
736760

737761
.heading {
738762
h3 {

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<script defer src="{{ site.baseurl }}/js/github.js" async></script>
2121

2222
<div class="section" id="intro">
23-
<h2 class="aos" data-aos="fadein-expand-up">EXPERIENCE</h2>
23+
<h2 class="aos stickyheader" data-aos="fadein-expand-up">EXPERIENCE</h2>
2424

2525
<h3 class="aos" data-aos="fadein-up"> I'm great at... </h3>
2626

@@ -106,7 +106,7 @@ <h3>Golang</h3>
106106

107107

108108
<div class="section" id="portfolio">
109-
<h2 class="aos" data-aos="fadein-expand-up">PROJECTS</h2>
109+
<h2 class="aos stickyheader" data-aos="fadein-expand-up">PROJECTS</h2>
110110

111111
<p class="aos" data-aos="fadein-up"> Check out a few of my creations. Pulled from <a href="https://github.com/{{ site.github_username }}">my GitHub</a>.</p>
112112
<div class="row card-columns gh-projects">
@@ -144,7 +144,7 @@ <h3></h3>
144144
</div>
145145

146146
<div class="section" id="contact">
147-
<h2 class="aos" data-aos="fadein-expand-up">FIND ME</h2>
147+
<h2 class="aos stickyheader" data-aos="fadein-expand-up">FIND ME</h2>
148148

149149
<div class="aos" data-aos="fadein-up" class="contact-slides" style="margin-bottom: 1em;">
150150
<!-- icons -->

js/main.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ ready(() => {
198198
if (nav.classList.contains('scrolled')) nav.classList.remove("scrolled");
199199
}
200200

201-
updateCheckpoints(checkpointContainer)
201+
sectionActions(checkpointContainer)
202202
}, 150);
203203

204-
function updateCheckpoints(container) {
204+
function sectionActions(container) {
205205
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
206206
// width to set the scroll progress bar to
207207
let newWidth = 0;
@@ -219,6 +219,18 @@ ready(() => {
219219
*/
220220
newWidth = Math.min(increment*(i + (vh - rect.top) / (rect.bottom - rect.top)), 100)
221221
}
222+
223+
header = section.querySelector("h2.stickyheader")
224+
if (header) {
225+
// if the element is at the top of the screen
226+
if (rect.top < 0) {
227+
header.classList.add("sticky")
228+
header.style.transform = `scale(10) translateX(${(rect.top) / (rect.bottom - rect.top - vh)*30}%)`
229+
} else {
230+
header.classList.remove("sticky")
231+
header.style.transform = null
232+
}
233+
}
222234
})
223235
container.querySelector("#checkpoint-fill").style.width = `${newWidth}%`
224236
const circlesToFill = Math.floor((newWidth+1)/increment)

0 commit comments

Comments
 (0)