F200v7 — Community Cards Scroll in Sync with Fences
Jira: HEDGE-222 Phase: 3 (UI & Presentation) Status: ✅ Implemented (V7 only)Business Rule
When the player advances to FLOP, TURN, or RIVER, the community cards for that stage must visually arrive on screen in sync with the stage fence post. The player experiences the cards “riding in” alongside the fence — reinforcing the metaphor that the board cards are revealed as each hurdle is crossed.- FLOP: 3 community cards arrive together (each docked to fence 3, the FLOP sign post)
- TURN: 1 community card arrives with the TURN sign post
- RIVER: 1 community card arrives with the RIVER sign post
x position relative to its fence post’s docked position.
Technical Design
DOM Structure
Five.grass-card elements are pre-created in .posts-layer at page load and hidden
(display:none). They are revealed and animated by scrollInCard() when the associated
fence reaches the viewport.
Scroll Mechanism
scrollInCard(cardEl, cardDockX) attaches a requestAnimationFrame loop that moves the
card element leftward at TRACK_PX_PER_SEC (400 px/s) until it reaches cardDockX.
The card is placed in .posts-layer, which shares coordinate space with the fence rAF loop,
so both fence post and card travel at the same speed and appear anchored together.
FLOP Sequence
FLOP spawns 3 fences sequentially, spacedHORSE_GAP (232 px) apart, to ensure horses
clear each fence before the next one appears:
All 3 FLOP cards scroll in simultaneously with fence 2.
TURN / RIVER Sequence
Single fence spawned immediately on Run click:
For RIVER,
spawnFinishFence() is called ~580ms after the RIVER fence spawns, giving the
river card time to dock before the finish line arrives.
onAllCleared Callback
Each stage fence is created with anonAllCleared callback. This fires when all active
(non-eliminated) horses have crossed the fence post. The callback triggers:
- Horse probability positions updated from the new snapshot (
percentWinvalues) - Eliminated horses (
percentWin <= 0) begin their scroll-off sequence (F204v7) waitForHorsesSettled()polling starts; Run button is re-enabled when horses settle
Key Constants
Acceptance Criteria
AC1. On FLOP Run click, 3 community card elements become visible and animate from the right edge of the track towardSTAGE_CARD_END_PX[0].
AC2. All 3 FLOP cards begin their animation at the same time as fence 2 (the FLOP sign
post fence), not at fence 0 or fence 1.
AC3. Each FLOP card decelerates and stops precisely at its STAGE_CARD_END_PX[0]
position; it does not overshoot or continue scrolling.
AC4. On TURN Run click, 1 community card scrolls in and docks at STAGE_CARD_END_PX[1]
in sync with the TURN fence post.
AC5. On RIVER Run click, 1 community card scrolls in and docks at STAGE_CARD_END_PX[2]
in sync with the RIVER fence post.
AC6. The RIVER card finishes docking before the finish-line fence arrives (~580ms later);
they do not visually collide.
AC7. Community cards and fence posts travel at exactly the same horizontal speed
(400 px/s); a card must never lead or trail its fence post horizontally during travel.
AC8. Community cards remain in their docked positions after the stage transition
completes; they are not removed or reset until the next HOLE (new round).