Skip to content

fix(CCarousel): use the vanilla swipe helper for touch navigation#476

Merged
mrholek merged 1 commit into
mainfrom
feat/carousel-touch-events
Jun 13, 2026
Merged

fix(CCarousel): use the vanilla swipe helper for touch navigation#476
mrholek merged 1 commit into
mainfrom
feat/carousel-touch-events

Conversation

@mrholek

@mrholek mrholek commented Jun 13, 2026

Copy link
Copy Markdown
Member

The carousel's touch handling was a simplified inline implementation: a 5px threshold, firing mid-gesture on touchmove, with no Pointer event support and no RTL awareness. This replaces it with a faithful port of the vanilla @coreui/coreui swipe helper.

What

  • New utils/Swipe — Pointer events with a Touch-event fallback, a 40px threshold, detecting the gesture on release (pointerup / touchend). Mirrors the vanilla util/swipe.js.
  • CCarousel now wires the helper through a single useEffect (keyed on touch), reading the latest handleControlClick via a ref to avoid stale closures.
  • RTL aware: swipe→prev/next mapping is flipped under dir="rtl" (matching vanilla's _directionToOrder), checked per gesture against the carousel element.

No public API change — the touch prop and onSlide / onSlid events are unchanged; only the gesture detection is corrected.

Tests & verification

  • New utils/__tests__/swipe.spec.ts covers threshold, direction, and dispose.
  • yarn lib:test — 365/365 passing · yarn lib:build OK · scoped lint clean (no new errors).

The inline touch handling used a 5px threshold and fired mid-gesture on
touchmove, with no Pointer event support and no RTL awareness. Replace it
with a Swipe helper ported from vanilla @coreui/coreui (pointer events
with a touch fallback, 40px threshold, detection on release), wired via a
single effect that respects RTL when mapping swipe direction to prev/next.
@mrholek mrholek merged commit e28800c into main Jun 13, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant