gesture-motion
Skill7 starsChanged 10 months agoMITView on GitHub
Physics-based motion patterns for touch and pointer gestures. Use for drag interactions, swipe actions, pull-to-refresh, pinch-zoom, and any direct manipulation UI.
In this repository87 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- motion-designSkill
- 3d-transformsSkill
- accessibilitySkill
- android-nativeSkill
- animation-recipesSkill
- anticipationSkill
- arc-motionSkill
- attention-choreographySkill
- attentionSkill
- audio-reactiveSkill
- blurSkill
- brand-animationSkill
- cameraSkill
- characterSkill
- choice-resolutionSkill
- cinematicSkill
- code-generationSkill
- colorSkill
- component-animationsSkill
- compositingSkill
- consequenceSkill
- container-transformSkill
- css-advancedSkill
- data-visualizationSkill
- depthSkill
- distortionSkill
- dramaturgySkill
- durationSkill
- easingSkill
- emotional-journeySkill
- emotion-mappingSkill
- emotion-selectionSkill
- empty-statesSkill
- entrance-patternsSkill
- exaggerationSkill
- exit-patternsSkill
- exportSkill
- figma-integrationSkill
- follow-throughSkill
- frame-timingSkill
- glow-shadowSkill
- intentSkill
- ios-nativeSkill
- loading-statesSkill
- loopingSkill
- lottieSkill
- masksSkill
- microstateSkill
- morphingSkill
- motion-auditSkill
- motion-blurSkill
- motion-principlesSkill
- motion-specsSkill
- narrative-arcSkill
- notificationsSkill
- onboardingSkill
- opacitySkill
- orchestratorSkill
- particlesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Clear thresholds: - When gesture triggers action
- Distinctive: line 212
Hard boundaries: - Use rubber-banding for natural feel
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gesture Motion Patterns
Motion that responds to user gestures with physics-based feedback. Direct manipulation should feel connected to the finger/pointer.
Core Principles
- 1:1 tracking during manipulation - Element follows pointer exactly
- Physics on release - Momentum, friction, snap points
- Resistance at boundaries - Rubber-banding effect
- Clear thresholds - When gesture triggers action
Pattern Categories
| Pattern | Gesture | Physics |
| Drag | Pointer down + move | Direct tracking, momentum on release |
| Swipe | Quick directional move | Velocity-based, snap points |
| Pull-to-refresh | Pull down past threshold | Resistance, spring back |
| Pinch-zoom | Two-finger pinch | Scale with damping |
| Rubber-band | Drag past boundary | Exponential resistance |
Drag Physics
Velocity Calculation
// Track velocity over last N samples
const velocityTracker = {
samples: [],
maxSamples: 5,
addSample(position, timestamp) {
this.samples.push({ position, timestamp });
if (this.samples.length > this.maxSamples) {
this.samples.shift();
}
},
getVelocity() {
if (this.samples.length < 2) return { x: 0, y: 0 };
const first = this.samples[0];
const last = this.samples[this.samples.length - 1];
const dt = (last.timestamp - first.timestamp) / 1000;
return {
x: (last.position.x - first.position.x) / dt,
y: (last.position.y - first.position.y) / dt
};
}
};Momentum Decay
function applyMomentum(element, velocity, friction = 0.95) {
let vx = velocity.x;
let vy = velocity.y;
function animate() {
vx *= friction;
vy *= friction;
// Continue until velocity is negligible
if (Math.abs(vx) > 0.5 || Math.abs(vy) > 0.5) {
requestAnimationFrame(animate);
}
}
animate();
}Swipe Patterns
Swipe Detection
const swipeConfig = {
threshold: 50, // Minimum distance
velocityThreshold: 0.5, // Minimum velocity (px/ms)
timeThreshold: 300 // Maximum time (ms)
};
function detectSwipe(start, end, duration) {
const dx = end.x - start.x;
const dy = end.y - start.y;
const distance = Math.sqrt(dx * dx + dy * dy);
const velocity = distance / duration;
if (distance < swipeConfig.threshold ||
velocity < swipeConfig.velocityThreshold) {
return null;
}
const angle = Math.atan2(dy, dx) * 180 / Math.PI;
if (angle >= -45 && angle < 45) return 'right';
if (angle >= 45 && angle < 135) return 'down';
if (angle >= -135 && angle < -45) return 'up';
return 'left';
}Snap Points
function snapToPoint(current, snapPoints, velocity) {
let target;
if (Math.abs(velocity) > 100) {
// High velocity: snap to next point in direction
target = velocity > 0
? snapPoints.find(p => p > current) || snapPoints[snapPoints.length - 1]
: [...snapPoints].reverse().find(p => p < current) || snapPoints[0];
} else {
// Low velocity: snap to nearest
target = snapPoints.reduce((nearest, point) =>
Math.abs(point - current) < Math.abs(nearest - current) ? point : nearest
);
}
return target;
}Rubber Banding
// Exponential resistance past boundary
function rubberBand(offset, maxOffset, elasticity = 0.55) {
if (Math.abs(offset) <= maxOffset) return offset;
const direction = offset > 0 ? 1 : -1;
const excess = Math.abs(offset) - maxOffset;
// Logarithmic falloff
const rubberBanded = maxOffset +
(1 - (1 / ((excess * elasticity / maxOffset) + 1))) * maxOffset;
return direction * rubberBanded;
}Implementation Presets
CSS Snap Points
/* Horizontal snap scroll */
.snap-container {
scroll-snap-type: x mandatory;
overflow-x: auto;
display: flex;
}
.snap-item {
scroll-snap-align: center;
flex-shrink: 0;
width: 80%;
}Framer Motion Draggable
// Draggable card with snap back
<motion.div
drag="x"
dragConstraints={{ left: 0, right: 0 }}
dragElastic={0.2}
onDragEnd={(e, info) => {
if (Math.abs(info.velocity.x) > 500 || Math.abs(info.offset.x) > 150) {
// Dismiss
} else {
// Snap back
}
}}
/>See references/gesture-implementations.md for complete GSAP, Framer Motion, and Remotion examples.
Accessibility
// Provide keyboard alternatives for gestures
const handleKeyDown = (e) => {
switch (e.key) {
case 'ArrowLeft': navigatePrev(); break;
case 'ArrowRight': navigateNext(); break;
case 'Delete': dismissItem(); break;
}
};
// Announce gesture actions
<div aria-live="polite">
{isDragging && 'Dragging item. Release to drop.'}
{isOverThreshold && 'Release to dismiss.'}
</div>Common Mistakes
- Not tracking velocity - Momentum needs velocity, not just position
- Hard boundaries - Use rubber-banding for natural feel
- Same physics for all gestures - Light swipe != heavy drag
- Ignoring inertia - Objects don't stop instantly
- No snap affordance - Visual hint where items will snap
Related Skills
animation-recipes- Pre-built gesture animation recipesaccessibility- Keyboard alternatives for gestureseasing- Spring physics for gesture animations
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

