Skip to content

[cssom-view] ScrollIntoViewOptions "nearest" description #4918

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

Open
zbianca opened this issue Apr 4, 2020 · 5 comments
Open

[cssom-view] ScrollIntoViewOptions "nearest" description #4918

zbianca opened this issue Apr 4, 2020 · 5 comments

Comments

@zbianca
Copy link

zbianca commented Apr 4, 2020

https://drafts.csswg.org/cssom-view/#element-scrolling-members

  1. Otherwise, block is "nearest":​

→ If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B
          Do nothing.

By this description nothing is done only when the element is bigger than the viewport.
However, another situation when nothing is done is when both edges are inside the box edges.
The same is valid for when inline is "nearest" on item 9.8.

@zbianca
Copy link
Author

zbianca commented Apr 4, 2020

My understanding is that two conditions need to be described, as follow:

→ If element edge A and element edge B are both inside scrolling box edge A and scrolling box edge B
→ If element edge A is outside scrolling box edge A and element edge B is outside scrolling box edge B
          Do nothing.

→ If element edge C and element edge D are both inside scrolling box edge C and scrolling box edge D
→ If element edge C is outside scrolling box edge C and element edge D is outside scrolling box edge D
          Do nothing.

@Loirooriol
Copy link
Contributor

By this description nothing is done only when the element is bigger

But if both A and B edges are inside, then the other conditions do not hold. So nothing is done either.

Then the spec seems fine already, your proposal would be just for completeness/clarification, right?

@zbianca
Copy link
Author

zbianca commented Apr 4, 2020

Yes, for completeness and clarity. Another option (just stating, not recommending it) would be to remove any "do nothing" cases then.
As long as there's no else statement at the end of the list, you could say the spec is fine already. But is it?

@Loirooriol
Copy link
Contributor

If you remove the initial "do nothing" case, then the other conditions may match when they are not supposed to.

@zbianca
Copy link
Author

zbianca commented Apr 4, 2020

Indeed.

To me the first condition illustrates only one possible situation: the element height is greater than the viewport and the element is currently taking all of the viewport. Please correct me if there's another possible situation. I'd be more secure about it if there was a 'respectively' there.

And with that consideration on the 1st condition when we get to the 3rd and 4th conditions we make sure that the opposite element edge not mentioned is inside its respective scrolling box edge without ever using the word inside. Maybe that was the intention here..

Back to my initial suggestion, from a practical point of view, knowing what happens when both edges are in view is extremely helpful since using "nearest" is the only way to achieve no scrolling ("do nothing").

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

3 participants