Skip to content

Commit 1f725cb

Browse files
committed
Simplified reduced motion implementation for content tabs
1 parent f3926bf commit 1f725cb

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

material/assets/javascripts/bundle.f881a9a8.min.js renamed to material/assets/javascripts/bundle.adc5bf89.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.f881a9a8.min.js.map renamed to material/assets/javascripts/bundle.adc5bf89.min.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.3714f473.min.css renamed to material/assets/stylesheets/main.052bca4c.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.3714f473.min.css.map renamed to material/assets/stylesheets/main.052bca4c.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% endif %}
3535
{% endblock %}
3636
{% block styles %}
37-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.3714f473.min.css' | url }}">
37+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.052bca4c.min.css' | url }}">
3838
{% if config.theme.palette %}
3939
{% set palette = config.theme.palette %}
4040
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
@@ -213,7 +213,7 @@
213213
</script>
214214
{% endblock %}
215215
{% block scripts %}
216-
<script src="{{ 'assets/javascripts/bundle.f881a9a8.min.js' | url }}"></script>
216+
<script src="{{ 'assets/javascripts/bundle.adc5bf89.min.js' | url }}"></script>
217217
{% for path in config["extra_javascript"] %}
218218
<script src="{{ path | url }}"></script>
219219
{% endfor %}

src/assets/javascripts/components/content/tabs/index.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ export function watchContentTabs(
103103
export function mountContentTabs(
104104
el: HTMLElement
105105
): Observable<Component<ContentTabs>> {
106-
const { matches: reduce } = matchMedia("(prefers-reduced-motion)")
107-
108-
/* Mount component on subscription */
109106
const container = getElement(".tabbed-labels", el)
110107
return defer(() => {
111108
const push$ = new Subject<ContentTabs>()
@@ -119,13 +116,11 @@ export function mountContentTabs(
119116
/* Handle emission */
120117
next([{ active }]) {
121118
const offset = getElementOffset(active)
122-
if (!reduce) {
123-
const { width } = getElementSize(active)
119+
const { width } = getElementSize(active)
124120

125-
/* Set tab indicator offset and width */
126-
el.style.setProperty("--md-indicator-x", `${offset.x}px`)
127-
el.style.setProperty("--md-indicator-width", `${width}px`)
128-
}
121+
/* Set tab indicator offset and width */
122+
el.style.setProperty("--md-indicator-x", `${offset.x}px`)
123+
el.style.setProperty("--md-indicator-width", `${width}px`)
129124

130125
/* Smoothly scroll container */
131126
container.scrollTo({

src/assets/stylesheets/main/extensions/pymdownx/_tabbed.scss

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
}
8989

9090
// [screen and no reduced motion]: Disable animation
91-
@media screen and (prefers-reduced-motion: no-preference) {
91+
@media screen {
9292

9393
// [js]: Show animated tab indicator
9494
.js & {
@@ -109,6 +109,11 @@
109109
transform 250ms;
110110
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
111111
content: "";
112+
113+
// [reduced motion]: Disable animation
114+
@media (prefers-reduced-motion) {
115+
transition: none;
116+
}
112117
}
113118
}
114119
}
@@ -234,11 +239,6 @@
234239
@media screen {
235240
color: var(--md-accent-fg-color);
236241

237-
// [reduced motion]: Show border
238-
@media (prefers-reduced-motion) {
239-
border-color: var(--md-accent-fg-color);
240-
}
241-
242242
// [no-js]: Show border (indicator is animated with JavaScript)
243243
.no-js & {
244244
border-color: var(--md-accent-fg-color);

0 commit comments

Comments
 (0)