Skip to content

Commit 688e214

Browse files
authored
fix(loader): respect prefers-reduced-motion (#103461)
#101654 was regretfully merged without a `(prefers-reduced-motion: reduce)` check. This PR implements that check to remove CSS animations and also the JS-driven bleep animation. <img width="828" height="574" alt="splash-loader-reduced-motion" src="https://github.com/user-attachments/assets/fb97ecd2-958e-43fe-9001-846d6e48133f" />
1 parent 5947261 commit 688e214

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/sentry/templates/sentry/partial/loader.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
stroke-dashoffset: -1150;
3838
}
3939
}
40+
@media (prefers-reduced-motion: reduce) {
41+
path {
42+
animation: none;
43+
stroke-dashoffset: 0;
44+
}
45+
}
4046
</style>
4147
<script>
4248
const host = document.currentScript.closest('svg');
@@ -115,7 +121,9 @@
115121
})
116122
}
117123
connectedCallback() {
118-
this.shuffle();
124+
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
125+
this.shuffle();
126+
}
119127
}
120128
disconnectedCallback() {
121129
cancelAnimationFrame(this.raf);

src/sentry/templatetags/sentry_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def org_url(organization, path, query=None, fragment=None) -> str:
111111
@register.simple_tag
112112
def loading_message():
113113
options = [
114-
"Loading a <scraps-bleep>&#%!</scraps-bleep>-ton of JavaScript&hellip;",
114+
"Loading a <scraps-bleep>$#!%</scraps-bleep>-ton of JavaScript&hellip;",
115115
"Escaping <code>node_modules</code> gravity well&hellip;",
116116
"Parallelizing webpack builders&hellip;",
117117
"Awaiting solution to the halting problem&hellip;",

static/index.ejs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
stroke-dashoffset: -1150;
8080
}
8181
}
82+
@media (prefers-reduced-motion: reduce) {
83+
path {
84+
animation: none;
85+
stroke-dashoffset: 0;
86+
}
87+
}
8288
</style>
8389
<script>
8490
const host = document.currentScript.closest('svg');
@@ -121,7 +127,7 @@
121127
</div>
122128
123129
<div class="loading-message">
124-
<p>Loading a <scraps-grawlix>&#%!</scraps-grawlix>-ton of JavaScript&hellip;</p>
130+
<p>Loading a <scraps-bleep>$#!%</scraps-bleep>-ton of JavaScript&hellip;</p>
125131
<p><small>You may need to disable adblocking extensions to load Sentry.</small></p>
126132
<script>
127133
function randomFrom(arr) {
@@ -130,7 +136,7 @@
130136
function randomBetween(min, max) {
131137
return Math.floor(Math.random() * (max - min - 1) + min);
132138
}
133-
customElements.define('scraps-grawlix', class extends HTMLElement {
139+
customElements.define('scraps-bleep', class extends HTMLElement {
134140
constructor() {
135141
super();
136142
this.shapes = '◆●▴▪×'.split('');
@@ -157,7 +163,9 @@
157163
})
158164
}
159165
connectedCallback() {
160-
this.shuffle();
166+
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
167+
this.shuffle();
168+
}
161169
}
162170
disconnectedCallback() {
163171
cancelAnimationFrame(this.raf);

0 commit comments

Comments
 (0)