Skip to content

v2.0.0

Latest

Choose a tag to compare

@vad1ym vad1ym released this 17 Jun 10:10

compare changes

🚀 Enhancements

  • flashcards: ⚠️ Remove deprecated approve/reject API (6ea94f8)
  • flashcards: ⚠️ Drive swipe animations with Web Animations API (3f8a4d3)
  • flashcards: Complete swipes on a fast flick (drag velocity) (d0d900e)
  • flashcards: Add peek() to nudge the active card (88a5ea2)
  • flashcards: ⚠️ Accessibility on by default (e2620ce)
  • flashcards: Add declarative swipe(direction) method (21cf77a)
  • flashcards: Add dev-only warnings for common misconfigurations (c7fb88a)

🔥 Performance

  • useStackList: Constant-time active-card lookup via positional cursor (8e1b29e)

💅 Refactors

  • useStackList: Model card lifecycle as an explicit state machine (fb678ea)
  • flashcards: ⚠️ Group related props into object props (63e0c92)

📖 Documentation

  • Refresh and restructure documentation (3e8d008)
  • Refresh and restructure documentation (8cbf6da)
  • Add no-style-included info (a69bf32)
  • Make docs beginner-friendly and align with grouped v2 API (b75466b)

❤️ Contributors

v2.0.0

New flick/peek/swipe API, accessibility on by default, Web Animations API engine, grouped object props. Several breaking changes — see Migration.

✨ Features

  • Accessibility on by default — single grouped a11y prop (boolean or A11yOptions):

    • Keyboard nav: arrows swipe enabled directions, Enter/Space = primary swipe, Backspace/z = restore. Optional confirmOnKey peeks then waits for confirmation (Escape cancels).
    • ARIA roles & labels on deck and active card; off-screen cards aria-hidden.
    • Visually-hidden aria-live announcer (liveMode, localizable labels, custom announce() builder).
    • prefers-reduced-motion: animations snap instantly, skip-shimmer suppressed (useReducedMotion).
    • Focus follows the active card after a keyboard swipe without stealing focus.
    • Opt out fully with :a11y="false". Exports A11yOptions / A11yProp / A11yAnnounceEvent.
  • Flick-to-swipe (drag velocity) — a fast flick completes a swipe even if released before swipeThreshold, matching native mobile feel. Velocity sign must match drag direction so opposite jitter never flings the wrong way. On by default; configured via the grouped velocity prop (null to disable).

  • peek(percent, direction?) — nudge the active card toward a direction (0–1 fraction of threshold) without completing the swipe. Same rotation/scale/indicators as mid-drag. Useful for hints and confirm-before-swipe flows. percent clamped 0–1; peek(0) settles back. Disabled directions ignored. Exposed on FlashCards and FlashCard.

  • swipe(direction) — declarative wrapper over swipeLeft/Right/Top/Bottom() taking direction as an argument; cleaner when direction is dynamic.

  • Dev-only warnings — tree-shakeable devWarn (guarded by import.meta.env.DEV, warns once) for common misconfigs: missing itemKey with no id field, empty swipeDirection, renderLimit < 1. itemKey narrowed to keyof T.

⚙️ Engine / Internals

  • Web Animations API replaces the CSS-keyframe + DOM-clone "ghost" system. Each card animates its own real element via element.animate() — the "last animating card vanishes" class of bugs is now structurally impossible. Also fixes button actions targeting the topmost visible card instead of the highest array-index one.
  • useStackList rewritten: explicit card-lifecycle state machine, constant-time active-card lookup via positional cursor (was O(n)), loop-mode edge-case fixes (cycle-boundary fast swipes, collapsed empty stack, off-center hang, rotation snap). Backed by invariant + benchmark tests.

💥 Breaking Changes

  • approve/reject API removed. Use the directional API instead: swipeRight/swipeTop = approve, swipeLeft/swipeBottom = reject. Removed: approve/reject events, #approve/#reject slots, approve()/reject() methods, actions-slot props, dual-emit aliases. dragmove no longer emits 'approve'/'reject'.

  • Flat props grouped into object props:

    Old (v1) New (v2)
    animationKeyframes / animationDuration / animationEasing animation { keyframes?, duration?, easing? }
    resistanceEffect / resistanceThreshold / resistanceStrength resistance { threshold?, strength? } | null
    swipeVelocityEnabled / swipeVelocityThreshold velocity { threshold? } | null

    Disable sentinel is null, not false (a | false union makes Vue infer a Boolean prop and silently disable default-on features).

  • .flash-card-animation--* CSS keyframe classes removed. Custom swipe/restore animations move to animation.keyframes — a callback returning only the off-screen fly-out frame (from center); the library supplies the rest. Exports defaultAnimationKeyframes / AnimationContext / AnimationKeyframes.

  • Deck DOM changed by default a11y — root gains tabindex/role/aria-*; hidden live-region nodes are rendered. Snapshot tests or strict DOM selectors may need updating; :a11y="false" restores the old DOM.

Migration

See docs/guide/migrating-to-v2.md (renamed from migrating-from-v0, with an index and a Deprecated API section).