Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition enter is not working in a specific (and strange) scenario #6024

Closed
adrianolobo opened this issue Jul 3, 2017 · 5 comments
Closed

Comments

@adrianolobo
Copy link

Version

2.3.0

Reproduction link

http://jsfiddle.net/Lv0w5ybr/

Steps to reproduce

  • Open the Jsfiddle
  • Watch after 1 sec the numbers not animating when entering
  • Click "Add" and see that the numbers are not being animated

What is expected?

  • Now open this other JSFiddle: http://jsfiddle.net/d51beego/
  • Watch after 1 sec the numbers are being animated correctly
  • Click "Add" and see that the numbers are being animated correctly

What is actually happening?

The difference between those JSFiddle is just a console.log(this.hPos) at the line 14.
For some reason, mixing this console.log(this.hPos); with the this.hPos = 'left'; makes the class 'animation-enter-to' not be removed and the enter animation not be fired.


I'm sorry If I don't have any additional info, I'm stuck with this error for 8 hours and I can't understand why a console.log could bug the animation.

@adrianwang
Copy link

I guess this related to Vue rendering mechanism. If you console.log(this); instead of console.log(this.hPos);, you can clearly see that even you put the console.log before change this.hPos's value, on Vue instance this.hPos has already changed to left.

@adrianolobo
Copy link
Author

I made a temporary fix by wrapping the content of getPosition with setTimeout(()=>{}, 0);. This 0ms delay solves the problem somehow. As you can see here: http://jsfiddle.net/Lnz3bn1s/1/
If I remove the .animation-move class the problem disapears too.
The console.log(this.hPos) was just an exemplo, if you test the variable with if(this.hPos) {...} it happens too.

@jkzing
Copy link
Member

jkzing commented Jul 7, 2017

I suppose this shouldn't be like that.

Did a little digging into it. It's because that accessing this.hPos will cause a re-render, and during that rendering, function that remove enter-to class is fired before enter-to class added.

I'll try to find a way get it fixed.

@jkzing
Copy link
Member

jkzing commented Jul 7, 2017

BTW, if you try to get work around it, wrap getPosition in this.$nextTick is a better idea.

@posva
Copy link
Member

posva commented Aug 11, 2017

Closing as dup of #5800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants