Performance: Transition parameters (duration, delay)
This affects how quickly transitions start and finish, impacting the smoothness and responsiveness of UI animations.
<div transition:fade={{ duration: 300, delay: 50 }}>Content</div><div transition:fade={{ duration: 5000, delay: 2000 }}>Content</div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Long duration and delay | Minimal | 0 | High due to long animation frames | [X] Bad |
| Short duration and delay | Minimal | 0 | Low, quick animation frames | [OK] Good |
duration parameter control in a transition?duration parameter defines the length of time the animation runs.delaydelay parameter controls waiting time before animation starts, not duration.transition:fade={{ delay: 500 }}.transition:fade={{ delay: 500 }} uses correct object syntax with colon and braces; others have invalid syntax.<div transition:fade={{ duration: 1000, delay: 500 }}>Hello</div>delay: 500 means wait 500ms before starting the fade.duration: 1000 means the fade animation lasts 1000ms (1 second).<div transition:fade={{ duration: '1000', delay: 200 }}>Hi</div><div transition:fade={{ duration: 2000, delay: 1000 }}>Content</div> uses correct syntax with numbers and proper object format.{{ delay: 2000, duration: 1000 }} is wrong; placing delay=2000 outside the transition directive is invalid.Pass the test and this pattern moves unknown