Skip to content

Commit

Permalink
feat: animate date indicators
Browse files Browse the repository at this point in the history
Using CSS scroll driven animations
  • Loading branch information
believer committed Sep 5, 2024
1 parent f90c3dc commit e6344ce
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,30 @@ video {
}
}

/* Scroll driven animation to fade in date indicators
* Note that the order of the properties seems to be important here,
* animation needed to be before animation-timeline.
* */

@media (prefers-reduced-motion: no-preference) and (min-width: 1024px) {
.year-indicator .year,
.month-indicator .month {
opacity: 0;
transform: translateY(50px);
animation: fade-in linear forwards;
animation-timeline: view();
/* Start at 0px (when it comes into view), end at half the screen height */
animation-range: 0 50vh;
}

@keyframes fade-in {
to {
opacity: 1;
transform: translateY(0);
}
}
}

.placeholder\:text-neutral-400::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(163 163 163 / var(--tw-text-opacity));
Expand Down
23 changes: 23 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,26 @@
.year-indicator + .month-indicator {
@apply -mt-6 lg:mt-0;
}

/* Scroll driven animation to fade in date indicators
* Note that the order of the properties seems to be important here,
* animation needed to be before animation-timeline.
* */
@media (prefers-reduced-motion: no-preference) and (min-width: 1024px) {
.year-indicator .year,
.month-indicator .month {
opacity: 0;
transform: translateY(50px);
animation: fade-in linear forwards;
animation-timeline: view();
/* Start at 0px (when it comes into view), end at half the screen height */
animation-range: 0 50vh;
}

@keyframes fade-in {
to {
opacity: 1;
transform: translateY(0);
}
}
}

0 comments on commit e6344ce

Please sign in to comment.