Issues Regarding TransitionGroup
bambooGHT opened this issue · comments
Vue version
3.4.21
Link to minimal reproduction
Steps to reproduce
When there's a scrollbar and it's not at the top, clicking 'x' to delete an element doesn't only transition out with translateX(50%); it also transitions down.
What is expected?
It should transition solely with translateX(50%).
What is actually happening?
When the element is not at the top of the scroll bar, the transition when deleting the element is as if translateY(y); is also added.
System Info
No response
Any additional comments?
No response
Hello!
It seems to be the expected behavior of your codes, this part of the code
.list-leave-active { position: absolute; }
Causes the element to be positioned absolutely during transition, which means the element won't follow the usual flow of the document anymore. In this case, because u didn't specify its ancestor, it will have different behavior when it is scrolled vs when it isn't as it will be absolutely positioned against the viewport, you see this by manually adding absolute position to each test element. Here is ChatGpt explanation of it.
You can fix this either by
- Removing absolute positioning (.list-leave-active) in the transition. However this will cause the top and bottom element to snap at the end of transition instead of smoothly moving to position.
- By adding
position: relative
to .list-box1 class, however, it is still not a perfect solution as it will cause the .test element to move downward a little bit due to the fact that the scrolling container resizes. This container resizing is why upper element is not affected but bottom element is affected by this. If you don't like this, the only way left is to change the transition animation.
Hope this helps!
Hello!
It seems to be the expected behavior of your codes, this part of the code
.list-leave-active { position: absolute; }
Causes the element to be positioned absolutely during transition, which means the element won't follow the usual flow of the document anymore. In this case, because u didn't specify its ancestor, it will have different behavior when it is scrolled vs when it isn't as it will be absolutely positioned against the viewport, you see this by manually adding absolute position to each test element. Here is ChatGpt explanation of it.
You can fix this either by
- Removing absolute positioning (.list-leave-active) in the transition. However this will cause the top and bottom element to snap at the end of transition instead of smoothly moving to position.
- By adding
position: relative
to .list-box1 class, however, it is still not a perfect solution as it will cause the .test element to move downward a little bit due to the fact that the scrolling container resizes. This container resizing is why upper element is not affected but bottom element is affected by this. If you don't like this, the only way left is to change the transition animation.Hope this helps!
Thank you!
I really hope there is a perfect solution, but it seems impossible to achieve it at the moment, so I can only give up.