mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-30 18:24:35 +01:00
Fixed tab indicator animation for right-to-left languages
This commit is contained in:
parent
4b2a97a51d
commit
a32760bdee
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.ffa0dd14.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.3714f473.min.css' | url }}">
|
||||||
{% if config.theme.palette %}
|
{% if config.theme.palette %}
|
||||||
{% set palette = config.theme.palette %}
|
{% set palette = config.theme.palette %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
|
||||||
@ -213,7 +213,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.1cbe63b4.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.f881a9a8.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
import {
|
import {
|
||||||
Observable,
|
Observable,
|
||||||
Subject,
|
Subject,
|
||||||
|
animationFrameScheduler,
|
||||||
|
auditTime,
|
||||||
|
combineLatest,
|
||||||
defer,
|
defer,
|
||||||
finalize,
|
finalize,
|
||||||
fromEvent,
|
fromEvent,
|
||||||
@ -30,6 +33,8 @@ import {
|
|||||||
mapTo,
|
mapTo,
|
||||||
merge,
|
merge,
|
||||||
startWith,
|
startWith,
|
||||||
|
takeLast,
|
||||||
|
takeUntil,
|
||||||
tap
|
tap
|
||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
|
|
||||||
@ -37,7 +42,8 @@ import {
|
|||||||
getElement,
|
getElement,
|
||||||
getElementOffset,
|
getElementOffset,
|
||||||
getElementSize,
|
getElementSize,
|
||||||
getElements
|
getElements,
|
||||||
|
watchElementSize
|
||||||
} from "~/browser"
|
} from "~/browser"
|
||||||
|
|
||||||
import { Component } from "../../_"
|
import { Component } from "../../_"
|
||||||
@ -97,19 +103,29 @@ export function watchContentTabs(
|
|||||||
export function mountContentTabs(
|
export function mountContentTabs(
|
||||||
el: HTMLElement
|
el: HTMLElement
|
||||||
): Observable<Component<ContentTabs>> {
|
): Observable<Component<ContentTabs>> {
|
||||||
|
const { matches: reduce } = matchMedia("(prefers-reduced-motion)")
|
||||||
|
|
||||||
|
/* Mount component on subscription */
|
||||||
const container = getElement(".tabbed-labels", el)
|
const container = getElement(".tabbed-labels", el)
|
||||||
return defer(() => {
|
return defer(() => {
|
||||||
const push$ = new Subject<ContentTabs>()
|
const push$ = new Subject<ContentTabs>()
|
||||||
push$.subscribe({
|
combineLatest([push$, watchElementSize(el)])
|
||||||
|
.pipe(
|
||||||
|
auditTime(1, animationFrameScheduler),
|
||||||
|
takeUntil(push$.pipe(takeLast(1)))
|
||||||
|
)
|
||||||
|
.subscribe({
|
||||||
|
|
||||||
/* Handle emission */
|
/* Handle emission */
|
||||||
next({ active }) {
|
next([{ active }]) {
|
||||||
const offset = getElementOffset(active)
|
const offset = getElementOffset(active)
|
||||||
|
if (!reduce) {
|
||||||
const { width } = getElementSize(active)
|
const { width } = getElementSize(active)
|
||||||
|
|
||||||
/* Set tab indicator offset and width */
|
/* Set tab indicator offset and width */
|
||||||
el.style.setProperty("--md-indicator-x", `${offset.x}px`)
|
el.style.setProperty("--md-indicator-x", `${offset.x}px`)
|
||||||
el.style.setProperty("--md-indicator-width", `${width}px`)
|
el.style.setProperty("--md-indicator-width", `${width}px`)
|
||||||
|
}
|
||||||
|
|
||||||
/* Smoothly scroll container */
|
/* Smoothly scroll container */
|
||||||
container.scrollTo({
|
container.scrollTo({
|
||||||
|
@ -148,7 +148,7 @@ export function mountBackToTop(
|
|||||||
/* Handle complete */
|
/* Handle complete */
|
||||||
complete() {
|
complete() {
|
||||||
el.style.top = ""
|
el.style.top = ""
|
||||||
el.removeAttribute("data-md-state")
|
el.setAttribute("data-md-state", "hidden")
|
||||||
el.removeAttribute("tabindex")
|
el.removeAttribute("tabindex")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -87,14 +87,18 @@
|
|||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [screen and no reduced motion]: Disable animation
|
||||||
|
@media screen and (prefers-reduced-motion: no-preference) {
|
||||||
|
|
||||||
// [js]: Show animated tab indicator
|
// [js]: Show animated tab indicator
|
||||||
.js & {
|
.js & {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
// Tab indicator
|
// Tab indicator
|
||||||
&::after {
|
&::before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
display: block;
|
display: block;
|
||||||
width: var(--md-indicator-width);
|
width: var(--md-indicator-width);
|
||||||
height: 2px;
|
height: 2px;
|
||||||
@ -107,6 +111,7 @@
|
|||||||
content: "";
|
content: "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Webkit scrollbar
|
// Webkit scrollbar
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
@ -229,6 +234,11 @@
|
|||||||
@media screen {
|
@media screen {
|
||||||
color: var(--md-accent-fg-color);
|
color: var(--md-accent-fg-color);
|
||||||
|
|
||||||
|
// [reduced motion]: Show border
|
||||||
|
@media (prefers-reduced-motion) {
|
||||||
|
border-color: var(--md-accent-fg-color);
|
||||||
|
}
|
||||||
|
|
||||||
// [no-js]: Show border (indicator is animated with JavaScript)
|
// [no-js]: Show border (indicator is animated with JavaScript)
|
||||||
.no-js & {
|
.no-js & {
|
||||||
border-color: var(--md-accent-fg-color);
|
border-color: var(--md-accent-fg-color);
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
max-height 0ms 250ms,
|
max-height 0ms 250ms,
|
||||||
z-index 250ms;
|
z-index 250ms;
|
||||||
|
|
||||||
// [reduced-motion]: Disable animation
|
// [reduced motion]: Disable animation
|
||||||
@media (prefers-reduced-motion) {
|
@media (prefers-reduced-motion) {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@
|
|||||||
max-height 250ms,
|
max-height 250ms,
|
||||||
z-index 0ms;
|
z-index 0ms;
|
||||||
|
|
||||||
// [reduced-motion]: Disable animation
|
// [reduced motion]: Disable animation
|
||||||
@media (prefers-reduced-motion) {
|
@media (prefers-reduced-motion) {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@
|
|||||||
animation: pulse 2000ms infinite;
|
animation: pulse 2000ms infinite;
|
||||||
content: "";
|
content: "";
|
||||||
|
|
||||||
// [reduced-motion]: Disable animation
|
// [reduced motion]: Disable animation
|
||||||
@media (prefers-reduced-motion) {
|
@media (prefers-reduced-motion) {
|
||||||
transition: none;
|
transition: none;
|
||||||
animation: none;
|
animation: none;
|
||||||
@ -212,7 +212,7 @@
|
|||||||
background-color 250ms;
|
background-color 250ms;
|
||||||
animation: none;
|
animation: none;
|
||||||
|
|
||||||
// [reduced-motion]: Disable animation
|
// [reduced motion]: Disable animation
|
||||||
@media (prefers-reduced-motion) {
|
@media (prefers-reduced-motion) {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@
|
|||||||
transition: transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1);
|
transition: transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1);
|
||||||
content: attr(data-md-annotation-id);
|
content: attr(data-md-annotation-id);
|
||||||
|
|
||||||
// [reduced-motion]: Disable animation
|
// [reduced motion]: Disable animation
|
||||||
@media (prefers-reduced-motion) {
|
@media (prefers-reduced-motion) {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user