mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-15 03:17:40 +01:00
Fixed back-to-top button position for sticky navigation tabs
This commit is contained in:
parent
ff4cf19f8d
commit
f8a19dc06b
29
material/assets/javascripts/bundle.e0abf5b0.min.js
vendored
Normal file
29
material/assets/javascripts/bundle.e0abf5b0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
material/assets/javascripts/bundle.e0abf5b0.min.js.map
Normal file
7
material/assets/javascripts/bundle.e0abf5b0.min.js.map
Normal file
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
@ -213,7 +213,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.ff0eccb3.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.e0abf5b0.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -276,8 +276,8 @@ export function mountTableOfContents(
|
||||
viewport$
|
||||
.pipe(
|
||||
takeUntil(push$.pipe(takeLast(1))),
|
||||
debounceTime(250),
|
||||
distinctUntilKeyChanged("offset"),
|
||||
debounceTime(250),
|
||||
withLatestFrom(push$)
|
||||
)
|
||||
.subscribe(([, { prev }]) => {
|
||||
|
@ -27,10 +27,12 @@ import {
|
||||
combineLatest,
|
||||
distinctUntilChanged,
|
||||
distinctUntilKeyChanged,
|
||||
endWith,
|
||||
finalize,
|
||||
map,
|
||||
tap,
|
||||
withLatestFrom
|
||||
takeLast,
|
||||
takeUntil,
|
||||
tap
|
||||
} from "rxjs"
|
||||
|
||||
import { Viewport } from "~/browser"
|
||||
@ -129,25 +131,15 @@ export function mountBackToTop(
|
||||
el: HTMLElement, { viewport$, header$, main$ }: MountOptions
|
||||
): Observable<Component<BackToTop>> {
|
||||
const push$ = new Subject<BackToTop>()
|
||||
push$
|
||||
.pipe(
|
||||
withLatestFrom(header$
|
||||
.pipe(
|
||||
distinctUntilKeyChanged("height")
|
||||
)
|
||||
)
|
||||
)
|
||||
.subscribe({
|
||||
push$.subscribe({
|
||||
|
||||
/* Handle emission */
|
||||
next([{ hidden }, { height }]) {
|
||||
el.style.top = `${height + 16}px`
|
||||
next({ hidden }) {
|
||||
if (hidden) {
|
||||
el.setAttribute("data-md-state", "hidden")
|
||||
el.setAttribute("tabindex", "-1")
|
||||
el.blur()
|
||||
} else {
|
||||
el.style.top = ""
|
||||
el.removeAttribute("data-md-state")
|
||||
el.removeAttribute("tabindex")
|
||||
}
|
||||
@ -161,6 +153,16 @@ export function mountBackToTop(
|
||||
}
|
||||
})
|
||||
|
||||
/* Watch header height */
|
||||
header$
|
||||
.pipe(
|
||||
takeUntil(push$.pipe(endWith(0), takeLast(1))),
|
||||
distinctUntilKeyChanged("height")
|
||||
)
|
||||
.subscribe(({ height }) => {
|
||||
el.style.top = `${height + 16}px`
|
||||
})
|
||||
|
||||
/* Create and return component */
|
||||
return watchBackToTop(el, { viewport$, header$, main$ })
|
||||
.pipe(
|
||||
|
Loading…
Reference in New Issue
Block a user