Gestures & Cards5 min read
Interactive 120 FPS Physics Swipe Card Deck
Direct Definition & Architecture
A physics-based swipe card couples continuous touch pan translation with angular rotation. On finger release, user velocity determines whether the card springs back to origin or accelerates beyond screen bounds, triggering an exit callback.
Live Physics Canvas
120 FPS GPU RenderStiffness (Tension)320
Damping (Friction)24
Technical Specifications
Bundle Footprint
< 2.8 kB gzipped
Frame Rate
120 FPS Worklet Thread
Gesture Pipeline
PanGestureHandler + Velocity Preservation
Export Targets
React Native (Reanimated 3), React, SwiftUI
State Machine Graph
RestingCenter positioned with elevation shadow.
DraggingLinear offset tracked; rotation scaled by displacement.
DismissingSpring acceleration sends card offscreen beyond threshold.
RecoilSub-threshold release snaps back with organic oscillation.
Production Code Output
swipe-card.jsx
import React, { useState } from 'react';
import { motion, useMotionValue, useTransform } from 'framer-motion';
export function SwipeCard({ onDismiss, children }) {
const x = useMotionValue(0);
const rotate = useTransform(x, [-200, 200], [-18, 18]);
const opacity = useTransform(x, [-200, -120, 0, 120, 200], [0, 1, 1, 1, 0]);
return (
<motion.div
style={{ x, rotate, opacity }}
drag="x"
dragConstraints={{ left: 0, right: 0 }}
onDragEnd={(e, { offset, velocity }) => {
const swipe = Math.abs(offset.x) * velocity.x;
if (offset.x > 140 || swipe > 1000) {
onDismiss?.('right');
} else if (offset.x < -140 || swipe < -1000) {
onDismiss?.('left');
}
}}
className="w-80 h-96 bg-white rounded-3xl shadow-xl border border-stone-200 cursor-grab active:cursor-grabbing p-6 flex flex-col justify-between select-none"
>
{children || <div className="text-stone-800 font-semibold">ExodeUI Swipe Card</div>}
</motion.div>
);
}Architectural Breakdown
Sluggish swipe cards compute bounds on the JavaScript thread, dropping frames on high-frequency touch updates.
ExodeUI compiles swipe decks into standalone UI thread worklets where translation and rotation are calculated within 8.33ms.
Momentum handoff ensures that fast flick gestures eject cleanly even if the finger lifted early.
Frequently Asked Questions
Explore Related Motion Guides & Tooling
Build your next living interface today.
Design fluid physics and visual logic in ExodeUI and export directly to React, Swift, and Flutter.