#How to use Motion exit when exiting, when there are many by doing exit child first?

19 messages · Page 1 of 1 (latest)

hardy tulip
#
<Presence exitBeforeEnter>
                <Show when={isShow()}>
                    <Motion.div class="grid grid-cols-2 fixed top-0 right-0 bg-red-500" initial={{ width: "0%" }} animate={{ width: "100%" }} exit={{ width: "0%" }}>
                        <Motion.div class="bg-black" initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ duration: 2 }} exit={{ opacity: 0 }} /> 
                        <div class="bg-pink-500">
                            <AiOutlineClose onclick={toggle} />
                        </div>
                    </Motion.div>
                </Show>
</Presence>
twilit pagoda
#

I think that the presence component waits only for it's direct child to exit before removing them from dom.
So you'd need to make sure that the root motion element has an animation duration the same or longer then the child.

hardy tulip
#

I assumed they were in order on exit as well because on initial they were in order.

twilit pagoda
#

they start entering and exiting immediately from what I remember

hardy tulip
#

I tried adding delay but it didn't work.

twilit pagoda
#

In the current version the direct child will have the exit transition triggered first. But I guess that shouldn't matter much.

twilit pagoda
hardy tulip
#

It just slows down before exiting the same way without ordering the animation.

twilit pagoda
#

I could make the next version wait for all children exit before removing from dom. I didn't know how important it was, and the vue implementation I was basing this on didn't have this either.

#

What do you mean by "ordering" exactly?

#

You want the child to finish exiting before parent starts?

hardy tulip
#

sorry for my translate i mean ```
initial > Motion 1 > Motion 2

Motion 2 > Motion 1 > exit
but it is Motion 1 > exit

#

when exit Motion 2 not trigger

twilit pagoda
#

ah
ok so I was overthinking the problem

hardy tulip
#

i must use library "@solid-primitives/transition-group" for this problem?

twilit pagoda
#

Not directly, I'm making it a dependency of the motionone implementation.
It doesn't help with your problem directly, but I think I've fixed it while working on it.

#

Or at least made it more consistent - I would assume that the exit transition would be triggered in the current version as well.

#

If you want, you could build the package locally from the version on the pr and check if it does solve your issue.