Fixed stealing of hash fragments when using navigation tracking

This commit is contained in:
squidfunk 2022-02-26 10:27:12 +01:00
parent e3c26215de
commit 8deb1c2425
6 changed files with 23 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@ -229,7 +229,7 @@ const content$ = defer(() => merge(
/* Table of contents */
...getComponentElements("toc")
.map(el => mountTableOfContents(el, { viewport$, header$ })),
.map(el => mountTableOfContents(el, { viewport$, header$, target$ })),
/* Back-to-top button */
...getComponentElements("top")

View File

@ -32,7 +32,9 @@ import {
finalize,
map,
of,
repeat,
scan,
skip,
startWith,
switchMap,
takeLast,
@ -83,6 +85,7 @@ interface WatchOptions {
interface MountOptions {
viewport$: Observable<Viewport> /* Viewport observable */
header$: Observable<Header> /* Header observable */
target$: Observable<HTMLElement> /* Location target observable */
}
/* ----------------------------------------------------------------------------
@ -247,7 +250,7 @@ export function watchTableOfContents(
* @returns Table of contents component observable
*/
export function mountTableOfContents(
el: HTMLElement, { viewport$, header$ }: MountOptions
el: HTMLElement, { viewport$, header$, target$ }: MountOptions
): Observable<Component<TableOfContents>> {
return defer(() => {
const push$ = new Subject<TableOfContents>()
@ -278,6 +281,9 @@ export function mountTableOfContents(
takeUntil(push$.pipe(takeLast(1))),
distinctUntilKeyChanged("offset"),
debounceTime(250),
skip(1),
takeUntil(target$.pipe(skip(1))),
repeat({ delay: 250 }),
withLatestFrom(push$)
)
.subscribe(([, { prev }]) => {