diff --git a/src/lib/components/transitions/TransitionChildWrapper.svelte b/src/lib/components/transitions/TransitionChildWrapper.svelte index 098e1c3..7bdc29a 100644 --- a/src/lib/components/transitions/TransitionChildWrapper.svelte +++ b/src/lib/components/transitions/TransitionChildWrapper.svelte @@ -10,11 +10,23 @@ {#if !hasTransition && hasOpen} - + {:else} - + {/if} diff --git a/src/lib/components/transitions/TransitionRoot.svelte b/src/lib/components/transitions/TransitionRoot.svelte index cfa072a..ec5e0ba 100644 --- a/src/lib/components/transitions/TransitionRoot.svelte +++ b/src/lib/components/transitions/TransitionRoot.svelte @@ -60,14 +60,12 @@ export function useNesting(done?: () => void) { let transitionableChildren: NestingContextValues["children"] = []; - let mounted = false; - onMount(() => (mounted = true)); - onDestroy(() => (mounted = false)); - function unregister(childId: ID, strategy = RenderStrategy.Hidden) { let idx = transitionableChildren.findIndex(({ id }) => id === childId); if (idx === -1) return; + let hadChildren = hasChildren(transitionableChildren); + match(strategy, { [RenderStrategy.Unmount]() { transitionableChildren.splice(idx, 1); @@ -77,7 +75,7 @@ }, }); - if (!hasChildren(transitionableChildren) && mounted) { + if (hadChildren && !hasChildren(transitionableChildren)) { done?.(); } } @@ -182,7 +180,14 @@ {#if state === TreeStates.Visible} - + {/if}