Traducción en curso
Este artículo cubre tres herramientas que puede usar para visualizar y editar animaciones:
Animation inspector
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.
From Firefox 41, the Page Inspector includes an extra view labeled "Animations".
This view displays CSS transitions and CSS animations synchronized along a timeline, with a draggable widget you can use to move to any point in the timeline and see the page at that point.
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
<div class="channel">
node. - 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
transition
was used to animate a property, and orange if a@keyframes
animation 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
@keyframes
animation. - 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,
span.channel-note
andimg#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:
- The
filter
property had a delay of 0.25 seconds applied to it. - The
transform
property transition ends after 0.5 seconds. - The
transform
property was animated on the compositor thread.
Animation playback
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:
Edit @keyframes
Any @keyframes rules associated with the currently selected element are displayed in the Rules view and are editable:
Edit timing functions
When you create a CSS animation you can specify a timing function: this determines the rate at which the animation progresses. One way to specify the timing function is with a cubic Bézier curve.
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":