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

ViewTransitions looses track of scroll position #8083

Closed
1 task done
martrapp opened this issue Aug 14, 2023 · 2 comments · Fixed by #8105
Closed
1 task done

ViewTransitions looses track of scroll position #8083

martrapp opened this issue Aug 14, 2023 · 2 comments · Fixed by #8105
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: view transitions Related to the View Transitions feature (scope)

Comments

@martrapp
Copy link
Member

martrapp commented Aug 14, 2023

What version of astro are you using?

2.10.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Chrome

Describe the Bug

When navigating back and forth with the keyboard, the client side router looses track of the correct scroll position.

What's the expected result?

When pressing back, forward, back, the second back should result in the same scroll position as the first.

I tried to figure out how the history, popstate and scroll status should work, but failed :-)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-rrjnk7?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 14, 2023
@natemoo-re natemoo-re added feat: view transitions Related to the View Transitions feature (scope) - P4: important Violate documented behavior or significantly impacts performance (priority) labels Aug 15, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 15, 2023
@martrapp
Copy link
Member Author

first hints: seems that the scroll handler updates history(-1).state with history(0) scroll position during transition...

@martrapp
Copy link
Member Author

I found an additional problem with throttling in the scroll event handler. It loses trailing scroll events.
For what the scroll handler does, the throttling here might be too much of a good thing.
Nonetheless, I've extended the throttling mechanism rather than removing it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: view transitions Related to the View Transitions feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants