Skip to content

Commit cdd3371

Browse files
zopsiclezopsicle
authored and
zopsicle
committed
rustdoc: do not animate when user prefers reduced motion
This accessibility improvement gates the target flashing and tooltip fade-out behind an inverted prefers-reduced-motion media query.
1 parent 0399709 commit cdd3371

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/librustdoc/html/static/css/rustdoc.css

+14-7
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,12 @@ instead, we check that it's not a "finger" cursor.
16871687
padding-right: 3px;
16881688
background-color: var(--target-background-color);
16891689
border-right: 3px solid var(--target-border-color);
1690-
animation: 0.65s cubic-bezier(0, 0, 0.1, 1.0) 0.1s targetfadein;
1690+
}
1691+
1692+
@media not (prefers-reduced-motion) {
1693+
:target {
1694+
animation: 0.65s cubic-bezier(0, 0, 0.1, 1.0) 0.1s targetfadein;
1695+
}
16911696
}
16921697

16931698
.code-header a.tooltip {
@@ -1712,12 +1717,14 @@ a.tooltip:hover::after {
17121717
content: "\00a0";
17131718
}
17141719

1715-
/* This animation is layered onto the mistake-proofing delay for dismissing
1716-
a hovered tooltip, to ensure it feels responsive even with the delay.
1717-
*/
1718-
.fade-out {
1719-
opacity: 0;
1720-
transition: opacity 0.45s cubic-bezier(0, 0, 0.1, 1.0);
1720+
@media not (prefers-reduced-motion) {
1721+
/* This animation is layered onto the mistake-proofing delay for dismissing
1722+
a hovered tooltip, to ensure it feels responsive even with the delay.
1723+
*/
1724+
.fade-out {
1725+
opacity: 0;
1726+
transition: opacity 0.45s cubic-bezier(0, 0, 0.1, 1.0);
1727+
}
17211728
}
17221729

17231730
.popover.tooltip .content {

0 commit comments

Comments
 (0)