1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2025-01-22 03:23:20 +01:00

Fixed instant navigation anchor scoll restoration issue

This commit is contained in:
squidfunk 2025-01-21 11:37:20 +07:00
parent c6fd95611d
commit 07a434b465
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
4 changed files with 9 additions and 14 deletions

View File

@ -249,7 +249,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.60a45f97.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.5090c770.min.js' | url }}"></script>
{% for script in config.extra_javascript %}
{{ script | script_tag }}
{% endfor %}

View File

@ -366,15 +366,10 @@ export function setupInstantNavigation(
// Handle instant navigation events that are triggered by the user clicking
// on an anchor link with a hash fragment different from the current one, as
// well as from popstate events, which are emitted when the user navigates
// back and forth between pages. We use a two-layered subscription to scope
// the scroll restoration to the current page, as we don't need to restore
// the viewport offset when the user navigates to a different page, as this
// is already handled by the previous observable.
// back and forth between pages.
document$.pipe(
switchMap(() => location$),
distinctUntilKeyChanged("pathname"),
switchMap(() => location$),
distinctUntilKeyChanged("hash")
distinctUntilKeyChanged("hash"),
),
// Handle instant navigation events that are triggered by the user clicking