-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5aead4
commit 6e267a0
Showing
6 changed files
with
215 additions
and
121 deletions.
There are no files selected for viewing
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,68 @@ | ||
/* Marquee styles */ | ||
.marquee { | ||
position: relative; | ||
overflow: hidden; | ||
user-select: none; | ||
} | ||
|
||
.marquee__content { | ||
flex-shrink: 0; | ||
min-width: 100%; | ||
} | ||
|
||
@keyframes scroll { | ||
from { | ||
transform: translateY(0); | ||
} | ||
to { | ||
transform: translateY(-100%); | ||
} | ||
} | ||
|
||
/* Pause animation when reduced-motion is set */ | ||
@media (prefers-reduced-motion: reduce) { | ||
.marquee__content { | ||
animation-play-state: paused !important; | ||
} | ||
} | ||
|
||
/* Enable animation */ | ||
.marquee .marquee__content { | ||
animation: scroll var(--length, 10s) linear infinite; | ||
} | ||
|
||
/* Reverse animation */ | ||
.marquee--reverse .marquee__content { | ||
animation-direction: reverse; | ||
} | ||
|
||
/* Pause on hover */ | ||
.marquee--hover-pause:hover .marquee__content { | ||
animation-play-state: paused; | ||
} | ||
|
||
/* Attempt to size parent based on content. Keep in mind that the parent width is equal to both content containers that stretch to fill the parent. */ | ||
.marquee--fit-content { | ||
max-width: fit-content; | ||
} | ||
|
||
/* A fit-content sizing fix: Absolute position the duplicate container. This will set the size of the parent wrapper to a single child container. Shout out to Olavi's article that had this solution 👏 @link: https://olavihaapala.fi/2021/02/23/modern-marquee.html */ | ||
.marquee--pos-absolute .marquee__content:last-child { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
} | ||
|
||
/* Enable position absolute animation on the duplicate content (last-child) */ | ||
.enable-animation .marquee--pos-absolute .marquee__content:last-child { | ||
animation-name: scroll-abs; | ||
} | ||
|
||
@keyframes scroll-abs { | ||
from { | ||
transform: translateX(100%); | ||
} | ||
to { | ||
transform: translateX(0); | ||
} | ||
} |
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
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
Oops, something went wrong.