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

Not working in safari/edge if you want to scroll document.body #292

Open
abraxxas opened this issue Feb 25, 2019 · 3 comments
Open

Not working in safari/edge if you want to scroll document.body #292

abraxxas opened this issue Feb 25, 2019 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@abraxxas
Copy link

It seems to work in both firefox and chrome for us if we want to scroll to the start of the body for example. But both in edge and safari the frames array is always empty if we use document.body as a target

@stipsan stipsan added the bug Something isn't working label May 13, 2019
@stipsan
Copy link
Member

stipsan commented May 27, 2020

Yeah that's because in those browsers the body is the scrolling element. You can verify this by checking document.scrollingElement.
The reason why it works firefox and chrome is that document.documentElement/<html> is the scrolling element there.

If you use the native scrollIntoView method on your usecases does it work then? Just so we can determine wether scrolling with document.body is a behavior that should work as in chrome when you're in other envs.

@abraxxas
Copy link
Author

Thanks for clearing that up, did not know that. In the end i fixed it by adding an invisible anchor element at the beginning of the body.

I just tested in safari and there using the native element scrolls to the beginning of the body as intended. I could not test on edge as i only have the new chrome based edge on hand currently

@stipsan
Copy link
Member

stipsan commented May 29, 2020

Yeah it caught me off guard as well. I discovered it while working on Browserstack tests.
I got some time to look into this some more earlier this evening. I noticed that when you call document.scrollingElement.scrollIntoView() in both Safari and Chrome they both scroll the page to the top. What you discovered is definitely what I'd classify as a bug.

I plan on implementing scroll-margin and scroll-padding support next, as these properties are no longer exclusive to scroll-snap logic but also affect scrollIntoView and page fragment scrolling in firefox and chrome betas. It's going to take time to implement this spec, thus I'll mark this as a "good first issue" and leave it open to signal to the community that PRs are welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants