-
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
Reconsider the names of properties on the VisualViewport interface #35
Comments
Just jumping late on the API spec here... I completely share @dbaron's concern on property name, starting with the API object name. @pp-koch's initial terminology works well for the API's documentation and the concept. But I find I suggest a more straight forward While this API relates to the viewport; In CSS terms, it does not technically represent the CSS viewport. So I think we should actually get away from using the same names (including terms such as scale). I propose the following changes:
I am replacing The And replacing That's my take so far. I'll leave that for others to review. |
Thanks for the suggestions. I'll reply to each property below:
I like it,
What do you mean by "CSS viewport"? This area is notoriously unspec'd so there isn't much that's agreed upon. In particular though, I prefer
I'd actually go further and just call these
I'm not sure I understand your rationale here. "client" means "viewport" relative in other areas. i.e.
Agree, this is probably fine. |
You are right. I got confused on what that scale is though. If I understand correctly, to allow for variable initial scales like I do here. PS: The argument has been made here already.
Ok, in that case it's "relative to the origin of the padding edge of the document" as per Mouse events.
I think my reasoning was about not including a fixed inner scroll. But that's probably out of scope in this context. No change needed on pageX|Y. |
I believe it's fairly easy to go from one interpretation of scale to another and I'd like to avoid adding many notions of scale as that'll make it rather confusing for authors. The definition as currently stated (scale relative to ideal) is really the scale of a CSS pixel relative to the device independent pixel (DIP) and it's useful since it's convenient for physical pixel calculations. That is, to go from CSS pixels to physical pixels we have You can still easily get the scale relative to your custom viewport width with
These values are relative to the layout viewport rather than document. That's a good point about which edge though...I think we want to use the margin edge. If you think of the (unzoomed, desktop) viewport, adding a margin on or doesn't extend the margin past the scrollbars. This seems to be a special case for the viewport in that margin is treated almost like an "outer padding". I think it would be weird though if, when fully scrolled to the top left, the visualViewport would had a negative offset. |
Can this account for https://drafts.csswg.org/css-logical-props/ using the names blockSize and inlineStart for example? This would account for text direction. |
The visual viewport doesn't have any content though and, as such, is agnostic to text direction itself. Though its position relative to the layout viewport / page could be thought of in terms of block and inline directions, I'm not sure it provides any benefit vs choosing a physical origin since it has no content of its own. |
Is fair yeah, the only benefit would be persuading people to use those properties over height/width etc. |
So we discussed w3ctag/design-reviews#128 a bit more in today's TAG meeting. I think most TAG members did agree that the naming situation isn't great. One thing that came to mind was having an API that's based on One other thought (mainly from me, not discussed much in the meeting) is that this could bear a distant relation to APIs for coordinate space conversion, e.g., as discussed in a 2013 public-pointer-events thread. We'd like to see this spec move forward and don't want to hold it up over naming, but we'd also like, if possible, to see names that will be easier for developers to remember and work with. |
I've updated the spec with the following naming:
What do folks think of this? @dbaron Would it be possible to get TAG to take a quick look at the names again? |
This updates the naming of the properties and viewport object itself: `window.visualViewport` -> `window.view` `scrollLeft` -> `offsetLeft` `scrollTop` -> `offsetTop` `pageX` -> `pageLeft` `pageY` -> `pageTop` `clientWidth` -> `width` `clientHeight` -> `height` For #35
I've further updated the spec with some more recommendations from TAG so the API currently looks like this:
Absent any compelling counterarguments I'm inclined to leave this bikeshed as-is. |
Creating an issue from dbaron's concern here: w3ctag/design-reviews#128
The names are a hodgepodge of things from other places in the platform (Element and MouseEvent).
Need to consider the relative values of having (1) a sensible API, locally vs. (2) an API whose names share meaning with names elsewhere in the platform.
The text was updated successfully, but these errors were encountered: