Skip to content

Commit 52b5357

Browse files
authored
Add scroll-direction state and updated overflowing state to scrollable in the explainer (#12130)
* Add scroll-direction state and updated owerflowing state to scrollable * Applied review comments * Specified recent/active scroll-direction state, renamed to * Modified open questions * Applied review comments
1 parent efce067 commit 52b5357

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

css-conditional-5/scroll_state_explainer.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,51 @@ a carousel.
147147

148148
- [Author request on github](https://github.com/w3c/csswg-drafts/issues/7430)
149149

150-
### Overflowing
150+
### Scrollable
151151

152-
Query whether a container has scrollable overflow. Can be used to indicate
153-
there is content to scroll to in a given direction.
152+
Query whether a container has [scrollable overflow](https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region).
153+
Can be used to indicate there is content to scroll to in a given direction.
154154

155-
Needs further exploration.
155+
### Direction
156+
157+
Query the most recent direction of [scrolling](https://drafts.csswg.org/cssom-view/#scrolling).
158+
For instance:
159+
160+
```css
161+
@container scroll-state(direction: top) {
162+
.scrolling-up {
163+
translate: 0 0;
164+
}
165+
}
166+
```
167+
168+
#### Workaround
169+
170+
A workaround solution to create queries based on scrolling direction is
171+
described in [Solved by CSS Scroll-Driven Animations: hide a header when
172+
scrolling down, show it again when scrolling up](https://www.bram.us/2024/09/29/solved-by-css-scroll-driven-animations-hide-a-header-when-scrolling-up-show-it-again-when-scrolling-down/),
173+
uses a `transition-delay` trick to get the active scroll direction.
174+
175+
#### Use Cases and Author Requests
176+
177+
To hide/show or partially collapse some content based on the direction of
178+
scrolling.
179+
180+
- [Author request on github](https://github.com/w3c/csswg-drafts/issues/6400)
181+
182+
#### Active scroll direction
183+
184+
The proposed `direction` feature matches the state of the most recent
185+
scroll direction. Web authors might also want to create queries based on the
186+
current scroll direction, not only the most recent one, similar to [scrollend
187+
event](https://drafts.csswg.org/cssom-view/#eventdef-document-scrollend).
188+
189+
This needs further discussion with the working group.
190+
191+
#### Programmatic scrolling
192+
193+
The question about which programmatic scrolls should affect scroll direction
194+
feature is discussed in [the issue](https://github.com/w3c/csswg-drafts/issues/12394).
156195

157196
### Anchor position fallback
158197

@@ -192,6 +231,42 @@ Query values for `stuck`:
192231
Query values for `snapped`:
193232

194233
- `none`
234+
- `x`
235+
- `y`
236+
- `block`
237+
- `inline`
238+
- `both`
239+
240+
Query values for `scrollable`:
241+
242+
- `none`
243+
- `top`
244+
- `right`
245+
- `bottom`
246+
- `left`
247+
- `block-start`
248+
- `inline-start`
249+
- `block-end`
250+
- `inline-end`
251+
- `x`
252+
- `y`
253+
- `block`
254+
- `inline`
255+
256+
257+
Query values for `direction`:
258+
259+
- `none`
260+
- `top`
261+
- `right`
262+
- `bottom`
263+
- `left`
264+
- `block-start`
265+
- `inline-start`
266+
- `block-end`
267+
- `inline-end`
268+
- `x`
269+
- `y`
195270
- `block`
196271
- `inline`
197272

0 commit comments

Comments
 (0)