Trabajar con animaciones
Este artículo cubre tres herramientas que puede usar para visualizar y editar animaciones:
Aunque esta herramienta se introdujo en Forefox 41, el interface de usuario se rediseñó en Forefox 43. This article describes the animation inspector as it appears in Firefox 43 and subsequent releases. If you want to see what the animation inspector looks like in Firefox 41 and 42, see this separate page.
Desde Firefox 41, el Inspector de Página incluye una vista extra etiquetada "Animaciones".
Esta vista muestra las transiciones CSS y las animaciones CSS sincronizadas en la linea de tiempo, puede usar el widget dragueable para moverse a cualquier punto en la linea de tiempo y ver la página en ese punto.
To see how it works, we'll walk through an example. The box below contains three grayscale icons, each representing a different Firefox channel. If you click an icon, the icon enlarges and changes to color, and the name of the channel appears. Click the icon again to reverse the effect. These animations are made by applying transitions to several CSS properties.
Let's use the animation inspector to see what's going on in this example.
- Using Firefox 43 or later, right-click one of the icons and select "Inspect Element".
- You'll probably also want to adjust the selected node up a level, to the
- Switch over to the "Animations" tab.
Now play the animation:
Let's take a closer look at the contents of the animation inspector here:
It shows a synchronized timeline for every CSS property transition involved in the animation. The timeline starts at the start of the first transition, and ends at the end of the last transition, and is labeled with markers every 100 milliseconds (this depends on the time scale of the animations currently displayed). You can see that the example above takes 735 milliseconds to run.
Each animation or transition is shown as a horizontal bar laid across the timeline:
- The bar is blue if a
transitionwas used to animate a property, and orange if a
@keyframesanimation was used.
- From Firefox 44 onwards, the bar contains a lightning bolt icon () if the property was animated using the compositor thread (see more about the cost of animating different CSS properties).
- The bar is labeled with the name of the property being animated or the name of the
- If the animation or transition had a delay, this is shown as a cross-hatched portion of the bar.
- If you hover over the bar, a tooltip appears, giving you more detailed information about the animation or transition.
To the left of each bar is a selector for the node that the animation applies to. If you hover over this selector, the node is highlighted in the page. Click the selector to select the node in the inspector.
To the left of the selector is a "target" icon (). From Firefox 44, clicking this icon will lock the highlighter on the element.
Applying all this to our example, we can see that:
- The animation involved two elements,
img#selected.channel-icon. Hovering over these selectors, we can see that those elements are, respectively, the channel name "Firefox Nightly" and the channel icon:
- Each element had two properties animated:
filterproperty had a delay of 0.25 seconds applied to it.
transformproperty transition ends after 0.5 seconds.
transformproperty was animated on the compositor thread.
At the top of the animation inspector:
- there are buttons to play/pause and rewind the animation (new in Firefox 44)
- the current time in the animation is displayed (new in Firefox 44).
Finally, if you click inside the bar at the top of the timeline, you get a scrubber that you can drag left and right to move backwards and forwards through the animation, and pinpoint exactly what's happening when:
Timing functions defined as cubic Bézier curves get an icon in the Rules view. If you click the icon you get a visual editor for the curve, enabling you to drag P1 and P2, and see the results in the page:
This feature uses open source code from Lea Verou’s cubic-bezier.com.
The cubic Bézier editor includes a number of presets, grouped under "Ease-in", "Ease-out", and "Ease-in-out":