Skip to content

Commit 7b79149

Browse files
committed
feat: respect the reduced motion perference
1 parent 02d0802 commit 7b79149

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

app/components/Package/Header.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ onKeyStroke(
184184
// TODO: Maybe set this where it's not loaded here every load?
185185
const { user } = useAtproto()
186186
187+
const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)')
188+
187189
const likeAnimKey = shallowRef(0)
188190
const showLikeFloat = shallowRef(false)
189191
const likeFloatKey = shallowRef(0)
190192
let likeFloatTimer: ReturnType<typeof setTimeout> | null = null
191193
192194
const heartAnimStyle = computed(() => {
193-
if (likeAnimKey.value === 0) return {}
195+
if (likeAnimKey.value === 0 || prefersReducedMotion.value) return {}
194196
return {
195197
animation: likesData.value?.userHasLiked
196198
? 'heart-spring 0.55s cubic-bezier(0.34,1.56,0.64,1) forwards'
@@ -227,7 +229,7 @@ const likeAction = async () => {
227229
228230
likeAnimKey.value++
229231
230-
if (!currentlyLiked) {
232+
if (!currentlyLiked && !prefersReducedMotion.value) {
231233
if (likeFloatTimer !== null) {
232234
clearTimeout(likeFloatTimer)
233235
likeFloatTimer = null
@@ -522,6 +524,12 @@ const likeAction = async () => {
522524
animation: float-up 0.75s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
523525
}
524526
527+
@media (prefers-reduced-motion: reduce) {
528+
.likeFloat {
529+
display: none;
530+
}
531+
}
532+
525533
@keyframes float-up {
526534
0% {
527535
opacity: 0;
@@ -578,4 +586,19 @@ const likeAction = async () => {
578586
transform: scale(1);
579587
}
580588
}
589+
590+
@media (prefers-reduced-motion: reduce) {
591+
@keyframes heart-spring {
592+
from,
593+
to {
594+
transform: scale(1);
595+
}
596+
}
597+
@keyframes heart-unlike {
598+
from,
599+
to {
600+
transform: scale(1);
601+
}
602+
}
603+
}
581604
</style>

0 commit comments

Comments
 (0)