Haptic
Fixed-duration vibration, transient impacts, and continuous haptic curves
Haptic
Module: jindong-compose | Package: io.github.compose.jindong.dsl
Emits a vibration event for the specified duration.
Signature
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
duration | Duration | - | How long the vibration lasts |
intensity | HapticIntensity | MEDIUM | Vibration strength |
Description
Haptic creates a single vibration event in the haptic pattern. The event is scheduled relative to previous events in the pattern.
Usage
Basic Usage
With Intensity
Custom Intensity
Sequential Haptics
Events run one after another:
With Delays
Examples
Single Tap Feedback
Double Tap Pattern
Success Feedback
Fade Out
Transient and Continuous
Use the common rich event model through these Compose functions:
Both use io.github.compose.jindong.dsl. Build shared curves with io.github.compose.jindong.core.dsl.hapticCurve:
A transient has zero logical duration. Use Delay to separate impacts.
A continuous event requires a positive duration. Curves replace the corresponding fixed value and must end at the event duration.
Sharpness and curve values must be finite and within 0..1.
The core DSL applies the same validation and produces equal compiled values.
As with Haptic and Clip, values are captured when the pattern compiles.
Include changing values in Jindong trigger keys when they must update the pattern.
See Migrating to 2.0 for curve and compatibility rules.
Platform Behavior
| Platform | Implementation |
|---|---|
| Android | VibrationEffect.createWaveform() |
| iOS | CHHapticEvent (HapticContinuous) played via CHHapticEngine |
Notes
- Duration is the haptic event length, not a delay
- Events are sequential by default
- Use
Delayto add gaps between haptics - Intensity values are normalized (0.0 to 1.0)