-
Hi there 👋. I have encountered a problem and am looking for an elegant way to solve it. I have 2 tabs, one of which has a popup mounted in The problem is that when I switch tabs, the tab that has I would like to make the Demo: https://svelte.dev/playground/e820aac2b926414fb75544feb038bfa6?version=5.27.0 I'm really hoping for your help. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
If that's the case, why do you specify an out transition? Why not just use an in transition? |
Beta Was this translation helpful? Give feedback.
-
I am a bit surprised that the lifetimes are automatically coupled. This usually relies on code being synchronous, which appears to be the case here as well, so you can break the coupling by using $effect(() => {
let instance;
setTimeout(() => {
instance = mount(Popup, {target: document.body})
})
return () => {
if (instance)
unmount(instance, {outro: true})
}
}) |
Beta Was this translation helpful? Give feedback.
I am a bit surprised that the lifetimes are automatically coupled.
This usually relies on code being synchronous, which appears to be the case here as well, so you can break the coupling by using
setTimeout
. It is a bit of hack but seems to work.