1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 01:10:58 +01:00

Fixed rendering of back-to-top button when used with sticky tabs

This commit is contained in:
squidfunk 2021-07-10 11:03:23 +02:00
parent 7ca4ca1a90
commit 7abeb68708
4 changed files with 14 additions and 12 deletions

View File

@ -223,7 +223,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.8400c76f.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.d7b0ad22.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 %}

View File

@ -43,7 +43,7 @@ import {
setBackToTopOffset, setBackToTopOffset,
setBackToTopState setBackToTopState
} from "~/actions" } from "~/actions"
import { Viewport } from "~/browser" import { Viewport, setElementFocus } from "~/browser"
import { Component } from "../_" import { Component } from "../_"
import { Header } from "../header" import { Header } from "../header"
@ -103,7 +103,7 @@ export function watchBackToTop(
.pipe( .pipe(
map(({ offset: { y } }) => y), map(({ offset: { y } }) => y),
bufferCount(2, 1), bufferCount(2, 1),
map(([a, b]) => a > b), map(([a, b]) => a > b && b),
distinctUntilChanged() distinctUntilChanged()
) )
@ -153,10 +153,12 @@ export function mountBackToTop(
/* Update state */ /* Update state */
next([{ hidden }, { height }]) { next([{ hidden }, { height }]) {
setBackToTopOffset(el, height + 16) setBackToTopOffset(el, height + 16)
if (hidden) if (hidden) {
setBackToTopState(el, "hidden") setBackToTopState(el, "hidden")
else setElementFocus(el, false)
} else {
resetBackToTopState(el) resetBackToTopState(el)
}
}, },
/* Reset on complete */ /* Reset on complete */