You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In that context, if you swap array[0] and array[1], none of the receive and send transition will be triggered, because Svelte considerers that <div class=element /> did not went out, then in the DOM, even though it does not correspond to the same array element before and after the swap. https://svelte.dev/repl/92dca5bdbeef4b939a10eb426b5807e5?version=3.20.1
There is however a way to make it work using a keyed each block wrapper around the element you want to use send and receive with.
Consider this sample code
In that context, if you swap
array[0]
andarray[1]
, none of thereceive
andsend
transition will be triggered, because Svelte considerers that<div class=element />
did not went out, then in the DOM, even though it does not correspond to the samearray
element before and after the swap.https://svelte.dev/repl/92dca5bdbeef4b939a10eb426b5807e5?version=3.20.1
There is however a way to make it work using a
keyed each
block wrapper around the element you want to usesend
andreceive
with.Using a
keyed each
block wrapper makes Svelte acknowledge that the elements actually changed, and then trigger thereceive
andsend
transition.https://svelte.dev/repl/da8f3f844c07429c8a8fe401adde3092?version=3.20.1
It however seems like a hack since a
keyed each
block wasn't designed for this. Could there be any other way to handle this ?The text was updated successfully, but these errors were encountered: