Performance: Bounce animation (attention)
MEDIUM IMPACT
Bounce animations affect the visual stability and interaction responsiveness by triggering repaints and potentially layout shifts.
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(20px); }
}
.element {
animation: bounce 1s infinite;
will-change: transform;
}@keyframes bounce {
0%, 100% { top: 0; }
50% { top: 20px; }
}
.element {
position: relative;
animation: bounce 1s infinite;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Animating 'top' property | None | 1 per frame | High (layout + paint) | [X] Bad |
| Animating 'transform: translateY()' | None | 0 | Low (composite only) | [OK] Good |