@angular/animations
Implements a domain-specific language (DSL) for defining web animation sequences for HTML elements as multiple transformations over time.
Use this API to define how an HTML element can move, change color, grow or shrink, fade, or slide off the page. These changes can occur simultaneously or sequentially. You can control the timing of each of these transformations. The function calls generate the data structures and metadata that enable Angular to integrate animations into templates and run them based on application states.
Animation definitions are linked to components through the animations
property in the @Component
metadata, typically in the component file of the HTML element to be animated. The trigger()
function encapsulates a named animation, with all other function calls nested within. Use the trigger name to bind the named animation to a specific triggering element in the HTML template.
Angular animations are based on CSS web transition functionality, so anything that can be styled or transformed in CSS can be animated the same way in Angular. Angular animations allow you to:
- Set animation timings, styles, keyframes, and transitions.
- Animate HTML elements in complex sequences and choreographies.
- Animate HTML elements as they are inserted and removed from the DOM, including responsive real-time filtering.
- Create reusable animations.
- Animate parent and child elements.
Additional animation functionality is provided in other Angular modules for animation testing, for route-based animations, and for programmatic animation controls that allow an end user to fast forward and reverse an animation sequence.
参见
Find out more in the animations guide.
See what polyfills you might need in the browser support guide.
入口点
Entry points
主要
Primary
@angular/animations | Implements a domain-specific language (DSL) for defining web animation sequences for HTML elements as multiple transformations over time. |
次要
Secondary
@angular/animations/browser | Provides infrastructure for cross-platform rendering of animations in a browser. |
@angular/animations/browser/testing | Provides infrastructure for testing of the Animations browser subsystem. |
主要入口点的导出
Primary entry point exports
类
Classes
AnimationBuilder | 一种可注入服务,可在 Angular 组件或指令中以编程的方式生成动画序列。由 An injectable service that produces an animation sequence programmatically within an Angular component or directive. Provided by the |
AnimationFactory | 从 A factory object returned from the |
NoopAnimationPlayer | 用于可复用动画的空白程序控制器。当禁用动画时在内部使用,以免在要用动画播放器时检查其是否为 null。 An empty programmatic controller for reusable animations. Used internally when animations are disabled, to avoid checking for the null case when an animation player is expected. |
函数
Functions
animate | 定义一个动画步骤,它把一些样式信息和时序信息组合在一起。 Defines an animation step that combines styling information with timing information. |
animateChild | 在一个动画序列中执行一个查询到的内部动画元素。 Executes a queried inner animation element within an animation sequence. |
animation | 生成一个可复用的动画,可以在其它动画或序列中通过 Produces a reusable animation that can be invoked in another animation or sequence, by calling the |
group | 定义一个可以并行运行的动画步骤列表。 Defines a list of animation steps to be run in parallel. |
keyframes | 可定义一组动画样式,每个样式都关联着一个可选的 Defines a set of animation styles, associating each style with an optional |
query | 在动画序列中正在播放的元素中查找一个或多个内部元素。和 Finds one or more inner elements within the current element that is being animated within a sequence. Use with |
sequence | 定义一个动画步骤列表,逐个依次运行它们。 Defines a list of animation steps to be run sequentially, one by one. |
stagger | 在调用 Use within an animation |
state | 在附加到元素的触发器上,声明一个动画状态。 Declares an animation state within a trigger attached to an element. |
style | 声明一个包含 CSS 属性/样式的键值对象,可在动画序列中用作动画状态( Declares a key/value object containing CSS properties/styles that can then be used for an animation |
transition | 声明一个转场动画,以便在满足给定条件时运行一系列动画步骤。该条件是一个逻辑型表达式或一个函数, 该函数比较以前和现在的动画状态,如果应该开始转场则返回 Declares an animation transition as a sequence of animation steps to run when a given condition is satisfied. The condition is a Boolean expression or function that compares the previous and current animation states, and returns true if this transition should occur. When the state criteria of a defined transition are met, the associated animation is triggered. |
trigger | 创建一个有名字的动画触发器,包含一个 Creates a named animation trigger, containing a list of |
useAnimation | 启动一个使用 Starts a reusable animation that is created using the |
结构
Structures
AnimateChildOptions | 添加持续时间选项,以控制子动画的动画样式和时序。 Adds duration options to control animation styling and timing for a child animation. |
AnimationAnimateChildMetadata | 封装一个子动画,父动画可以显式的运行它。 由 Encapsulates a child animation, that can be run explicitly when the parent is run. Instantiated and returned by the |
AnimationAnimateMetadata | 封装一个动画步骤。由 Encapsulates an animation step. Instantiated and returned by the |
AnimationAnimateRefMetadata | 封装一个可复用的动画。 由 Encapsulates a reusable animation. Instantiated and returned by the |
AnimationEvent | 在开始或完成阶段调用已捕获动画的回调时,将此类的实例作为事件参数返回。 An instance of this class is returned as an event parameter when an animation callback is captured for an animation either during the start or done phase. |
AnimationGroupMetadata | 封装一个动画组。 由 Encapsulates an animation group. Instantiated and returned by the |
AnimationKeyframesSequenceMetadata | 封装一个关键帧序列。由 Encapsulates a keyframes sequence. Instantiated and returned by the |
AnimationMetadata | 动画数据结构的基类。 Base for animation data structures. |
AnimationMetadataType | 一组可以为动画定义参数类别的常量。 Constants for the categories of parameters that can be defined for animations. |
AnimationOptions | 用来控制动画样式和时序的选项。 Options that control animation styling and timing. |
AnimationPlayer | 提供对可复用动画序列的编程控制,该动画序列是使用 Provides programmatic control of a reusable animation sequence, built using the |
AnimationQueryMetadata | 封装一个动画查询。由 Encapsulates an animation query. Instantiated and returned by the |
AnimationQueryOptions | 封装一些动画查询选项。 传给 Encapsulates animation query options. Passed to the |
AnimationReferenceMetadata | 封装一个可复用的动画,包括一组独立的动画步骤。由 Encapsulates a reusable animation, which is a collection of individual animation steps. Instantiated and returned by the |
AnimationSequenceMetadata | 封装一个动画序列。 由 Encapsulates an animation sequence. Instantiated and returned by the |
AnimationStaggerMetadata | 封装一组动画步骤的起始时间的交错参数。 由 Encapsulates parameters for staggering the start times of a set of animation steps. Instantiated and returned by the |
AnimationStateMetadata | 通过将状态名称和一组 CSS 样式相关联来封装一个动画状态。 由 Encapsulates an animation state by associating a state name with a set of CSS styles. Instantiated and returned by the |
AnimationStyleMetadata | 封装一个动画样式。由 Encapsulates an animation style. Instantiated and returned by the |
AnimationTransitionMetadata | 封装一个转场动画。由 Encapsulates an animation transition. Instantiated and returned by the |
AnimationTriggerMetadata | 包含一个动画触发器。由 Contains an animation trigger. Instantiated and returned by the |
类型
Types
AUTO_STYLE | 用于指定自动化样式。 Specifies automatic styling. |
AnimateTimings | 表示一个动画步骤中的动画时序参数。 Represents animation-step timing parameters for an animation step. |