Skip to content

Commit 436b4b0

Browse files
committed
📝 add mode-switching via Clay_GetScrollContainerData to scroll spec
1 parent 2e222be commit 436b4b0

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

specs/scroll-spec.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,24 @@ When decoding a clip configuration, the C side:
156156
1. Reads axis modes from the packed word.
157157
2. Sets `decl.clip.horizontal` / `decl.clip.vertical` to true for any non-zero
158158
mode.
159-
3. For manual axes, reads the offset from the buffer.
159+
3. For manual axes, reads the offset from the buffer and writes it into Clay's
160+
internal scroll state via `Clay_GetScrollContainerData`. This keeps Clay's
161+
scroll position in sync so that switching to pointer mode on a subsequent
162+
frame continues from the manual position.
160163
4. For pointer axes, reads the offset from `Clay_GetScrollOffset()`.
161164
5. Combines both into `decl.clip.childOffset`.
162165

163166
This happens while the element is open (between `Clay__OpenElementWithId` and
164167
`Clay__ConfigureOpenElement`), so `Clay_GetScrollOffset()` resolves to the
165168
correct element.
166169

170+
### 7.1 Mode switching
171+
172+
Because manual mode writes to Clay's scroll state every frame, and pointer mode
173+
reads from it, the two modes are always in sync. The caller can freely alternate
174+
between numeric and `"pointer"` values on any axis between frames without
175+
jumps or discontinuities. No explicit mode-switching logic is needed.
176+
167177
---
168178

169179
## 8. Invariants
@@ -216,13 +226,19 @@ bounding box contains the event's coordinates.
216226
12. Manual axis is unaffected by wheel events.
217227
13. Pointer axis ignores manual values (uses engine state).
218228

229+
### Mode switching
230+
231+
14. Switch from manual to pointer — pointer continues from manual position.
232+
15. Switch from pointer to manual — manual overrides pointer position.
233+
16. Rapid alternation between modes — no jumps or discontinuities.
234+
219235
### Edge cases
220236

221-
14. Clip with no children — no crash, empty output.
222-
15. Nested scroll containers — inner container gets priority for wheel.
223-
16. Scroll container removed between frames — no stale state.
224-
17. Wheel event with no scroll containers under pointer — no effect.
225-
18. Wheel event with only manual-mode containers under pointer — no effect.
237+
17. Clip with no children — no crash, empty output.
238+
18. Nested scroll containers — inner container gets priority for wheel.
239+
19. Scroll container removed between frames — no stale state.
240+
20. Wheel event with no scroll containers under pointer — no effect.
241+
21. Wheel event with only manual-mode containers under pointer — no effect.
226242

227243
---
228244

0 commit comments

Comments
 (0)