1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-14 19:07:41 +01:00

Fixed anchor navigation when using instant loading

This commit is contained in:
squidfunk 2021-12-02 18:52:00 +01:00
parent b6ca0a1053
commit ebcd000fdc
4 changed files with 10 additions and 10 deletions

View File

@ -213,7 +213,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.e0abf5b0.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.33f85c42.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

@ -326,13 +326,13 @@ export function setupInstantLoading(
/* Emit history state change */
merge(push$, pop$)
.pipe(
sample(document$),
sample(document$)
)
.subscribe(({ url, offset = { y: 0 } }) => {
.subscribe(({ url, offset }) => {
if (url.hash && !offset) {
setLocationHash(url.hash)
} else {
window.scrollTo(0, offset.y)
window.scrollTo(0, offset?.y || 0)
}
})
@ -354,7 +354,7 @@ export function setupInstantLoading(
filter(([a, b]) => a.url.pathname === b.url.pathname),
map(([, state]) => state)
)
.subscribe(({ offset = { y: 0 } }) => {
window.scrollTo(0, offset.y)
.subscribe(({ offset }) => {
window.scrollTo(0, offset?.y || 0)
})
}