Re: [csswg-drafts] [css-scroll-snap] Multiple nested scrollers and a "default" scrollIntoView()?

The proposed solution seems reasonable though as pointed out it adds complexity.

This means that we are now allowing snap and align to be simultaneously honored depending on the container. This is fine but it is odd that the only possible alignment option is the default alignment. I think this is not very user friendly and provides for an odd API. 

This issue is actually caused by the original resolution which makes snap application depend on presence of alignment.

I also have a second concern with original proposal. The way it works if a user specifies an alignment we
ignore the snap position. But that means the next user scroll **will snap**. I understand that this may be the
desired behavior in some usecases but I don't feel escaping snapping and this secondary snap induced scroll is the right **default**. 

## Alternative proposal

Since the spec has not been updated and no one has implemented then I suppose we have a chance to reconsider the original resolution. Here is an alternative idea:

Introduce a `snap` property to ScrollIntoViewOptions that explicitly controls snapping behavior independent of the alignment. By default it is `true` but then it can be set to `false` to disable snapping.

```webidl
dictionary ScrollIntoViewOptions : ScrollOptions {
  ScrollLogicalPosition block = "start";
  ScrollLogicalPosition inline = "nearest";
  boolean snap = true; 
};
```

I think giving authors an explicit way to disable snapping provides a better API. Also it is better suited if in future we decide to provide a similar option for other scrolling API (e.g., `focus()`, `scrollBy()`).

So in this particular case:
- If author has explicitly requested disabling snap via `snap:false` we don't snap any ancestor container and apply the requested alignment (which can be other than default).
- Otherwise, snap for ancestors that are snap containers, and align for ancestors that are not based on the specified or the default alignment.

-- 
GitHub Notification of comment by majido
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2593#issuecomment-384357311 using your GitHub account

Received on Wednesday, 25 April 2018 16:52:48 UTC