-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add scrollTo and scrollBy to viewport object #3
Comments
Would the scrollTo arguments be relative to the layout viewport? Or relative to the page, like window.scrollTo? |
I think that's an interesting point. Our current proposal has fields relative to the layout viewport as well as the page. We found that having pageX and pageY makes it easier to do things using the API. I can see cases where its useful to have both. For example, if a page has a "scroll to bottom" button, calling visualViewport.scrollTo should probably scroll the visual viewport relative to the page. On the contrary, if a page wants move the viewport when the user pinch zooms in to have an element fully visible, it is probably easier to have visualViewport.scrollTo be relative to the layout viewport? Perhaps we need to consider some compelling cases for scrollTo and scrollBy before adding it. |
I have a case: you tap on an input inside a partially collapsed section, it expands upon focus, screen keyboard appears and visual viewport is moved making input positioned incorrectly after expansion. I thought that with visual viewport API I could just scroll screen accordingly, but it appears it all just readonly stuff, even though everywhere it says «query and set», in title of the proposal here, MDN etc. |
Not sure I fully understand (if the input is inside a collapsed section, how can you tap it?). More generally, input focus seems like something that should be performed by the user agent, not the author having to manually use script. If that's not happening correctly perhaps it's a browser bug? |
I should have said «partially collapsed». Edited. Attached an example. You tap the input, it gets focused and keyboard appears. I want the sheet to expand in that case so I do it upon focus. But that's beyond the point, why on earth would this be a readonly API? Browsers address bars appear and disappear beyond our control, on the bottom, on the top, iPhones zoom in on inputs if font size is below 15px, screen keyboard can cover important parts etc. We have control of everything, why don't we have control over the position of the visual viewport? |
This would allow CSSOM style smooth-scrolling and passing ScrollToOptions
The text was updated successfully, but these errors were encountered: