Open typhonrt opened 1 month ago
Is there a workaround to solve this issue? I'd like to use a portal based on mount
and Svelte transitions, but unmount
destroys the content ignoring outro transitions.
So far the only thing that comes to mind is to wrap the contents of the portaral in a condition and switch this condition first, and call unmount
on the outroend
event, but I would like a simpler solution. Thanks.
I'm looking for a way to run transitions without component destruction (assuming I control DOM removal myself). This feature request would greatly help with that. Something like this could be perfect for my use-case:
export async function unmount(component: Record<string, any>, options?: { outro?: boolean, destroy?: boolean }): Promise<void>;
Describe the problem
With Svelte 3 & 4 using a crafty workaround with code example at the end of this issue it is possible to destroy components after outro transitions are run.
Svelte 3&4 related issue: https://github.com/sveltejs/svelte/issues/4056
Is there any comparable
svelte/internal
mechanisms accessible in Svelte 5 to achieve the same result? I have not found a corresponding capability yet in upgrading my framework to Svelte 5. This would be a rather debilitating situation without a solution for various use cases required by my framework.It would be nice if
unmount
in Svelte could take an options object with { outro: boolean } and return a Promise. IE run outro transition, destroy / unmount component and then resolve the Promise.This would make the declaration:
The Svelte 3 & 4 solution to the problem:
Describe the proposed solution
Modify
unmount
to take an options object indicating that the outro transition should run and complete before unmounting returning a Promise. Or provide an alternateunmountWithOutro
function.Importance
i cannot use svelte without it / blocking upgrade to Svelte 5.