diff --git a/src/assets/javascripts/components/toc/index.ts b/src/assets/javascripts/components/toc/index.ts index d7825146c..27a266f94 100644 --- a/src/assets/javascripts/components/toc/index.ts +++ b/src/assets/javascripts/components/toc/index.ts @@ -161,6 +161,13 @@ export function watchTableOfContents( }, new Map()) }), + /* Sort index by vertical offset */ + map(index => ( + new Map( + [...index].sort(([, offsetA], [, offsetB]) => offsetA - offsetB) + ) + )), + /* Re-compute partition when viewport offset changes */ switchMap(index => combineLatest([adjust$, viewport$]) .pipe(