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

Add scrollTo and scrollBy to viewport object #3

Open
bokand opened this issue Mar 18, 2016 · 5 comments
Open

Add scrollTo and scrollBy to viewport object #3

bokand opened this issue Mar 18, 2016 · 5 comments

Comments

@bokand
Copy link
Collaborator

bokand commented Mar 18, 2016

This would allow CSSOM style smooth-scrolling and passing ScrollToOptions

@staktrace
Copy link
Contributor

Would the scrollTo arguments be relative to the layout viewport? Or relative to the page, like window.scrollTo?

@ymalik
Copy link
Collaborator

ymalik commented Aug 30, 2016

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.

@waterplea
Copy link

waterplea commented Sep 6, 2023

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.

@bokand
Copy link
Collaborator Author

bokand commented Sep 11, 2023

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?

@waterplea
Copy link

waterplea commented Sep 12, 2023

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?

Screenshot_2023-09-12-06-18-31-340_com.android.chrome.jpg

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

No branches or pull requests

4 participants