Reputation: 1866
Is there a consistent way to determine if a popstate is caused by the forward or the back button?
I am currently saving a time stamp in the state when a new page is added, which means that navigation is working correct for the most parts, but if for instance there are three pages loaded using history.push and the user navigates back to the second and refreshes it, the time stamp is renewed, and therefor the animation starts to get all weird, because the forward is now to a page with a lower timestamp, triggering the back animation.
The behavior can be reproduced in http://goo.gl/26MlRW by adding two screens, then going back once and refresh the page.
Code for the example: http://goo.gl/pDGctA
Upvotes: 4
Views: 331
Reputation: 1866
Okay i found a way to fix the bug, which was to look at the current history.state when the script is invoked, and if it contained a time stamp, then use it as the current views time stamp, as the current state are actually transferred between refreshes
Upvotes: 2