Quick Start
Build your first haptic pattern with Jindong in minutes
Quick Start
Let's build your first haptic feedback pattern with Jindong.
This guide covers the Compose API (jindong-compose module). For non-Compose usage, see Core API Guide.
Minimal Example
That's it! Every time you tap the button, a 100ms haptic pulse fires.
Understanding the Basics
JindongProvider
Provides the haptic execution context:
Jindong
The main composable for defining haptic patterns:
- Works like
LaunchedEffect - Executes when any key changes
- Content block defines the pattern
Haptic
Creates a vibration:
Building Patterns
Sequential Events
Events execute one after another:
Adding Delays
Use Delay for pauses between events:
Adjusting Intensity
Control vibration strength:
Repetition
Repeat patterns with Repeat:
Practical Examples
Screen Entry Feedback
Use Unit as key to trigger haptic immediately when entering a screen:
Button Tap Feedback
Success Notification
Error Alert
Fade Out Effect
Heartbeat Pattern
Common Patterns
| Pattern | Key | Code |
|---|---|---|
| On screen enter | Jindong(Unit) | Haptic(100.ms) |
| Single tap | Jindong(count) | Haptic(50.ms) |
| Double tap | Jindong(count) | Repeat(2) { Haptic(40.ms); Delay(40.ms) } |
| Long press | Jindong(count) | Haptic(200.ms, HapticIntensity.MEDIUM) |
| Success | Jindong(success) | Haptic(50.ms); Delay(50.ms); Haptic(100.ms) |
| Error | Jindong(error) | Repeat(3) { Haptic(80.ms); Delay(50.ms) } |
Tips
Key Management
Choose keys carefully:
Next Steps
- Jindong API - Deep dive into the main API
- Composable DSL - All DSL primitives
- HapticIntensity - Intensity options