Skip to content

Commit

Permalink
Fix contents onmount (#3878)
Browse files Browse the repository at this point in the history
* Contents.svelte calls update(), highlight() twice on mount

* fix timeout

* use document.fonts.ready

Co-authored-by: Janosh Riebesell <[email protected]>
  • Loading branch information
Rich-Harris and janosh authored Feb 14, 2022
1 parent 9ee4934 commit f412dc5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions sites/kit.svelte.dev/src/lib/docs/Contents.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
/** @type {number[]} */
let positions = [];
onMount(() => {
// wait for fonts to load...
const timeouts = [setTimeout(onresize, 1000), setTimeout(onscroll, 5000)];
onMount(async () => {
await document.fonts.ready;
return () => {
window.removeEventListener('scroll', onscroll, true);
window.removeEventListener('resize', onresize, true);
timeouts.forEach((timeout) => clearTimeout(timeout));
};
update();
highlight();
});
afterNavigate(() => {
Expand Down

0 comments on commit f412dc5

Please sign in to comment.