Duration
The duration option sets the duration of the panel snap animation in milliseconds.
- JavaScript
- React
- Vue@3
Summary
Key Options
| Option | Type | Default | Description |
|---|---|---|---|
duration | number | 500 | Animation duration (ms) |
Comparison by Value
| Value | Behavior | Suitable For |
|---|---|---|
100 or less | Near-instant snap | UI requiring fast response, games |
300-500 | Natural speed | General carousels, image galleries |
1000 or more | Slow transition | Presentations, emphasis effects |
Details
How Duration Works
After finishing a drag and releasing, the panel snaps to the target position. duration is the time it takes for this snap animation to complete.
// Various duration values
duration: 100 // Fast snap (0.1s)
duration: 500 // Default (0.5s)
duration: 1500 // Slow snap (1.5s)
duration: 0 // Move instantly without animation
Related Options
- Relationship with easing:
durationdetermines the animation time, whileeasingdetermines the animation curve. Combine both to create various transition effects. - Relationship with moveType: With
moveType: "freeScroll", inertial scrolling is applied and may behave differently from duration.
Use Cases
When to use?
- Short duration (100-300ms): UI where fast response matters, tab switching, game interfaces
- Default duration (400-600ms): General carousels, image galleries
- Long duration (800ms+): Presentations, onboarding, emphasizing transition effects
Notes
Using duration: 0
Setting duration: 0 causes instant movement without animation. Be cautious as the lack of visual feedback may confuse users.
Too long duration
A duration over 1 second may make users feel like they are waiting. Unless intentional, around 500ms is recommended.
Related Links
Related Options
Related Demos
- Easing: Adjusting the animation curve
- Movement Types: Movement behavior modes