tawasuyu

tawasuyu/brahman

Rust 329TOML 125JSON 17Markdown 144672 Definiciones

⎇ e570c6ca6fb6f5bc576e6a2f021d8b22a2209438 crates/modules/vista/SDD.md Markdown · 40 líneas · 1.4 KB Historia crudo

docs: fix factual errors en SDDs y STATUS/ROADMAP e570c6ca6 · sergio ·

1# modules/vista/ — Deck horizontal swipe (PageView)
2
3**Propósito.** Carousel/PageView estilo Flutter: gesto horizontal con
4snap a página, distinción horizontal vs vertical, soporte mouse +
5touch + pointer events. Lógica separada del binding DOM.
6
7## Crates
8
9| crate         | tipo | rol                                                       |
10| ------------- | ---- | --------------------------------------------------------- |
11| `vista-core`  | lib  | `DeckState` agnóstico: pointer_down/move/end → outcomes   |
12| `vista-web`   | lib  | Binding DOM sobre `<strip>`: traduce eventos + aplica CSS |
13
14## Dependencias
15
16- `vista-core`: sin deps externas. Pura state machine.
17- `vista-web` ← `vista-core`, `wasm-bindgen`, `web-sys` (PointerEvent).
18
19## API agnóstica (vista-core)
20
21```rust
22let mut deck = DeckState::new();
23deck.pointer_down(x, y, pointer_id, viewport_width);
24match deck.pointer_move(x, y) {
25    DragOutcome::StartHorizontal { pointer_id } => capture_pointer(),
26    DragOutcome::DragOffset(px) => apply_translate(px),
27    DragOutcome::CancelVertical => yield_to_scroll(),
28    DragOutcome::Idle => {}
29}
30if let Some(r) = deck.pointer_end(offset, width, n_pages) {
31    apply_translate(r.offset_px);
32    if r.changed { notify(r.target_index); }
33}
34```
35
36## Estado
37
38vista-core: 5 tests verdes (drag decision + snap + clamp + goto).
39vista-web: binding DOM intacto, ahora delega toda la lógica a core.
40LOC core 177 + web ~355. Reutilizable en backends no-web.

SDD.md

modules/vista/ — Deck horizontal swipe (PageView)

Propósito. Carousel/PageView estilo Flutter: gesto horizontal con snap a página, distinción horizontal vs vertical, soporte mouse + touch + pointer events. Lógica separada del binding DOM.

Crates

cratetiporol
vista-corelibDeckState agnóstico: pointer_down/move/end → outcomes
vista-weblibBinding DOM sobre <strip>: traduce eventos + aplica CSS

Dependencias

API agnóstica (vista-core)

let mut deck = DeckState::new();
deck.pointer_down(x, y, pointer_id, viewport_width);
match deck.pointer_move(x, y) {
    DragOutcome::StartHorizontal { pointer_id } => capture_pointer(),
    DragOutcome::DragOffset(px) => apply_translate(px),
    DragOutcome::CancelVertical => yield_to_scroll(),
    DragOutcome::Idle => {}
}
if let Some(r) = deck.pointer_end(offset, width, n_pages) {
    apply_translate(r.offset_px);
    if r.changed { notify(r.target_index); }
}

Estado

vista-core: 5 tests verdes (drag decision + snap + clamp + goto). vista-web: binding DOM intacto, ahora delega toda la lógica a core. LOC core 177 + web ~355. Reutilizable en backends no-web.