W3C home > Mailing lists > Public > www-style@w3.org > January 2016

Re: [css-snappoints][css-scroll-snap] scroll-snap-point-type and scroll-snap-align on the same element

From: Florian Rivoal <florian@rivoal.net>
Date: Tue, 26 Jan 2016 11:36:12 +0900
Cc: CSS public list <www-style@w3.org>
Message-Id: <A5514022-3102-4CAC-AC1D-2C95B0586CE5@rivoal.net>
To: "Tab Atkins Jr." <jackalmage@gmail.com>

> On Jan 26, 2016, at 04:25, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> 
> On Sun, Jan 24, 2016 at 4:40 AM, Florian Rivoal <florian@rivoal.net> wrote:
>> 
>> Can you do this?
>> 
>> div {
>>  height: 100px;
>>  overflow: scroll;
>>  scroll-snap-type: mandatory;
>>  scroll-snap-align: center;
>> }
>> 
>> or this?
>> 
>> div {
>>  height: 100px;
>>  overflow: scroll;
>>  scroll-snap-type: proximity;
>>  scroll-snap-align: end;
>> }
>> 
>> I assume that it does not work, because if it did, it would cause issues in the case of nested scrollers. The spec(s) should be (more) explicit about that.
> 
> You can *do* both of those, but they won't do what you seem to be
> expecting.  They'd control the snapping behavior of the container in
> *its* scrolling container.

That's what I meant by "the case of nested scrollers", sorry for not being clear.

> It's just like how align-content works on
> the parent but align-self works on the child; you can meaningfully put
> both on the same element, but they're doing different things in
> different contexts, not interacting with each other.

Right, that's how I expected things to work but I couldn't find which part of the spec says that explicitly, so I wasn't sure, and then wondered if it might be something else.

In the css-scroll-snap, the descriptions scroll-snap-align and scroll-snap-type do not speak of ancestors or descendants, and that's where I was looking for this info. I now have found where you say that: In section 4 https://drafts.csswg.org/css-scroll-snap/#snap-model: "Snap positions must only affect the nearest ancestor (on the element’s containing block chain) scroll container."

Matt's spec is clearer about this: that same sentence is in the overview, but in addition, the description of scroll-snap-align explains things in terms of ancestors or descendants. As you work with Matt to align the two specs, I suggest to align to his phrasing for this.

> What are you trying to do? As 'scroll-snap-align' is written, you can
> align a snapper to either edge, or the center of the box, and you can
> apply arbitrary offsets to this on either an individual child level
> (scroll-snap-margin) or the container level (scroll-snap-padding).
> What effect are you trying to achieve that's not covered by this?

I'm not particularly trying to achieve anything. I was just wondering, having run (using your spec) into a case which didn't seem clear, what was supposed to happen, and could think of two behaviors. With varying degrees of clarify, both specs agree on which one it is, so case closed.

I was mainly wondering whether this could be used to put a snap point at either edge of the scroller without worrying about what children it has or how they're laid out. It can't, and that's fine. In the cases I can think of when you might want a snap-point at the end, there's no particular difficulty in setting it via children of the scroller.

 - Florian
Received on Tuesday, 26 January 2016 02:36:39 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:34 UTC