|
| 1 | +import { component$ } from '@builder.io/qwik'; |
| 2 | +import { Note, NoteStatus } from '../note/note'; // Adjust the import path based on your structure |
| 3 | + |
| 4 | +export const TopLayerAnimationsCaveats = component$(() => { |
| 5 | + return ( |
| 6 | + <Note status={NoteStatus.Warning}> |
| 7 | + <strong>Important Caveats for Animating Discrete Properties</strong> |
| 8 | + |
| 9 | + <ul class="mt-4 list-disc bg-gradient-to-b pl-4"> |
| 10 | + <li> |
| 11 | + <strong> |
| 12 | + Animating <code>display</code> and <code>overlay</code>: |
| 13 | + </strong> |
| 14 | + <p> |
| 15 | + The <code>display</code> property must be included in the transitions list to |
| 16 | + ensure the element remains visible throughout the animation. The value flips |
| 17 | + from <code>none</code> to <code>block</code> at 0% of the animation, ensuring |
| 18 | + visibility for the entire duration. The |
| 19 | + <code>overlay</code> ensures the element stays in the top layer until the |
| 20 | + animation completes. |
| 21 | + </p> |
| 22 | + </li> |
| 23 | + <li> |
| 24 | + <strong> |
| 25 | + Using <code>transition-behavior: allow-discrete</code>: |
| 26 | + </strong> |
| 27 | + <p> |
| 28 | + This property is essential when animating discrete properties like{' '} |
| 29 | + <code>display</code> and <code>overlay</code>, which are not typically |
| 30 | + animatable. It ensures smooth transitions for these discrete properties. |
| 31 | + </p> |
| 32 | + </li> |
| 33 | + <li> |
| 34 | + <strong> |
| 35 | + Setting Starting Styles with <code>@starting-style</code>: |
| 36 | + </strong> |
| 37 | + <p> |
| 38 | + CSS transitions are only triggered when a property changes on a visible |
| 39 | + element. The |
| 40 | + <code>@starting-style</code> at-rule allows you to set initial styles (e.g.,{' '} |
| 41 | + <code>opacity</code> and |
| 42 | + <code>transform</code>) when the element first appears, ensuring that the |
| 43 | + animation behaves predictably. |
| 44 | + </p> |
| 45 | + </li> |
| 46 | + </ul> |
| 47 | + </Note> |
| 48 | + ); |
| 49 | +}); |
0 commit comments