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
{{ message }}
Repository navigation
Angular animation: :leave animation starts at wrong position #29526
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationslegacy animations package only. Otherwise use area: core.freq1: lowtype: bug/fix
Hi @mfursov and all, I've just created a PR with the fix 🙂 👆
The issue is as @marcusrettig suggested that :enter runs instead of :leave (also the other points he made are correct, as for why, keep reading and that should become quite clear 🙂), that is because when the elements in the list are moved their DOM elements are removed and re-inserted (PS: when reversing the array the last one is an exception since it, as a side effect gets moved/pushed down by the other n-1 items, that is why the last item in the reversed list doesn't present the issue)
The real issue here is that the reordering "triggers" the leaving of the elements, but then cancels it (you don't see them disappear or anything), as a side effect however the elements (again, except the last one) lose their trigger's value.
when you add the 3 items, in the console you can see that normal transitions from void to null occur (remember that void => * matches :enter)
when you reverse the list you will see 2 (and not 3, as I mentioned earlier) transitions from null to void (which match :leave) but the items haven't actually left the DOM nor any leave animation is executed
when you remove the 3 items, (as already mentioned) the last one (first to be removed) works fine (null to void) but the other 2 transition from void to void (it should be from null to void, but the null got lost/replaced widh void during the reordering)
by remembering that void to * (where * indicates anything) matches :enter we can now see why the :enter transition is executed instead of :leave (note: the first successful transition in the array cancels the others)
(also note that void to void also matched :leave/* => void so, if you switch the transitions in the array everything would work as expected even without my PR's fix)
(also feel free to experiment with the stackblitz, this also happens if we bind some value to the trigger, not only if the value is null)
(ps: if my explanation about the last item not being effected doesn't sound convincing, you can reverse the list 2 times, in that way you all the items are actually moved at least once by themselves and will have their trigger's values set to void and all transitions will be broken/look like :leave 🙂 )
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationslegacy animations package only. Otherwise use area: core.freq1: lowtype: bug/fix
Activity
malieop commentedon Mar 26, 2019
The problem only happens when you reverse your list order.
marcusrettig commentedon Jan 2, 2020
I have the same issue, here are my conclusions so far:
:entertransition runs instead of:leave.:enteris before:leavein the array passed totrigger(..).:leavetransition.dario-piotrowicz commentedon Dec 29, 2021
Hi @mfursov and all, I've just created a PR with the fix 🙂 👆
The issue is as @marcusrettig suggested that
:enterruns instead of:leave(also the other points he made are correct, as for why, keep reading and that should become quite clear 🙂), that is because when the elements in the list are moved their DOM elements are removed and re-inserted(PS: when reversing the array the last one is an exception since it, as a side effect gets moved/pushed down by the other n-1 items, that is why the last item in the reversed list doesn't present the issue)
The real issue here is that the reordering "triggers" the leaving of the elements, but then cancels it (you don't see them disappear or anything), as a side effect however the elements (again, except the last one) lose their trigger's value.
To explain better, please have a look at this updated stackblitz with console.logs, there:
voidtonulloccur (remember thatvoid => *matches:enter)nulltovoid(which match:leave) but the items haven't actually left the DOM nor any leave animation is executednulltovoid) but the other 2 transition fromvoidtovoid(it should be fromnulltovoid, but thenullgot lost/replaced widhvoidduring the reordering)by remembering that
voidto*(where*indicates anything) matches:enterwe can now see why the:entertransition is executed instead of:leave(note: the first successfultransitionin the array cancels the others)(also note that
voidtovoidalso matched:leave/* => voidso, if you switch thetransitions in the array everything would work as expected even without my PR's fix)(also feel free to experiment with the stackblitz, this also happens if we bind some value to the trigger, not only if the value is
null)(ps: if my explanation about the last item not being effected doesn't sound convincing, you can reverse the list 2 times, in that way you all the items are actually moved at least once by themselves and will have their trigger's values set to
voidand all transitions will be broken/look like:leave🙂 )I hope this helps clarifying things 🙂
fix(animations): retain triggers values for moved tracked list items (#…
angular-automatic-lock-bot commentedon Feb 7, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.