@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.

参见

入口点

主要

@angular/animations

Implements a domain-specific language (DSL) for defining web animation sequences for HTML elements as multiple transformations over time.

次要

@angular/animations/browser
@angular/animations/browser/testing

主入口点的导出

AnimationBuilder

An injectable service that produces an animation sequence programmatically within an Angular component or directive. Provided by the BrowserAnimationsModule or NoopAnimationsModule.

AnimationFactory

A factory object returned from the AnimationBuilder.build() method.

NoopAnimationPlayer

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.

函数

animate

定义一个动画步骤,它把一些样式信息和时序信息组合在一起。

Defines an animation step that combines styling information with timing information.

animateChild

在一个动画序列中执行一个查询到的内部动画元素。

Executes a queried inner animation element within an animation sequence.

animation

生成一个可复用的动画,可以在其它动画或序列中通过 useAnimation() 函数进行调用。

Produces a reusable animation that can be invoked in another animation or sequence, by calling the useAnimation() function.

group

定义一个可以并行运行的动画步骤列表。

Defines a list of animation steps to be run in parallel.

keyframes

可定义一组动画样式,每个样式都关联着一个可选的 offset 值。

Defines a set of animation styles, associating each style with an optional offset value.

query

在动画序列中正在播放的元素中查找一个或多个内部元素。和 animateChild() 一起使用。

Finds one or more inner elements within the current element that is being animated within a sequence. Use with animate().

sequence

定义一个动画步骤列表,逐个依次运行它们。

Defines a list of animation steps to be run sequentially, one by one.

stagger

在调用 query() 中使用可以在每个查询到的条目开始播放动画之后插入一个时间间隔。

Use within an animation query() call to issue a timing gap after each queried item is animated.

state

在附加到元素的触发器上,声明一个动画状态。

Declares an animation state within a trigger attached to an element.

style

声明一个包含 CSS 属性/样式的键值对象,可在动画序列中用作动画状态(state),或在调用 animate()keyframes() 时作为传入的样式数据。

Declares a key/value object containing CSS properties/styles that can then be used for an animation state, within an animation sequence, or as styling data for calls to animate() and keyframes().

transition

声明一个转场动画,以便在满足给定条件时运行一系列动画步骤。该条件是一个逻辑型表达式或一个函数, 该函数比较以前和现在的动画状态,如果应该开始转场则返回 true。 当满足所定义的转场动画的状态标准时,就会开始执行相关的动画。

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

创建一个有名字的动画触发器,包含一个 state()transition() 的列表,当此触发器的绑定表达式发生变化时,它们就会重新求值。

Creates a named animation trigger, containing a list of state() and transition() entries to be evaluated when the expression bound to the trigger changes.

useAnimation

启动一个使用 animation() 函数创建的可复用动画。

Starts a reusable animation that is created using the animation() function.

结构

AnimateChildOptions

添加持续时间选项,以控制子动画的动画样式和时序。

Adds duration options to control animation styling and timing for a child animation.

AnimationAnimateChildMetadata

封装一个子动画,父动画可以显式的运行它。 由 animateChild 函数进行初始化和返回。

Encapsulates a child animation, that can be run explicitly when the parent is run. Instantiated and returned by the animateChild function.

AnimationAnimateMetadata

封装一个动画步骤。由 animate() 函数进行实例化并返回。

Encapsulates an animation step. Instantiated and returned by the animate() function.

AnimationAnimateRefMetadata

封装一个可复用的动画。 由 useAnimation() 函数实例化并返回。

Encapsulates a reusable animation. Instantiated and returned by the useAnimation() function.

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

封装一个动画组。 由 group() 函数实例化并返回。

Encapsulates an animation group. Instantiated and returned by the group() function.

AnimationKeyframesSequenceMetadata

封装一个关键帧序列。由 keyframes() 函数进行实例化并返回。

Encapsulates a keyframes sequence. Instantiated and returned by the keyframes() function.

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 build() method of AnimationBuilder. The build() method returns a factory, whose create() method instantiates and initializes this interface.

AnimationQueryMetadata

封装一个动画查询。由 query() 函数实例化并返回。

Encapsulates an animation query. Instantiated and returned by the query() function.

AnimationQueryOptions

封装一些动画查询选项。 传给 query() 函数。

Encapsulates animation query options. Passed to the query() function.

AnimationReferenceMetadata

封装一个可复用的动画,包括一组独立的动画步骤。由 animation() 函数返回,并传给 useAnimation() 函数。

Encapsulates a reusable animation, which is a collection of individual animation steps. Instantiated and returned by the animation() function, and passed to the useAnimation() function.

AnimationSequenceMetadata

封装一个动画序列。 由 sequence() 函数进行实例化并返回。

Encapsulates an animation sequence. Instantiated and returned by the sequence() function.

AnimationStaggerMetadata

封装一组动画步骤的起始时间的交错参数。 由 stagger() 函数实例化并返回。

Encapsulates parameters for staggering the start times of a set of animation steps. Instantiated and returned by the stagger() function.

AnimationStateMetadata

通过将状态名称和一组 CSS 样式相关联来封装一个动画状态。 由 state() 函数实例化并返回。

Encapsulates an animation state by associating a state name with a set of CSS styles. Instantiated and returned by the state() function.

AnimationStyleMetadata

封装一个动画样式。由 style() 函数实例化并返回。

Encapsulates an animation style. Instantiated and returned by the style() function.

AnimationTransitionMetadata

封装一个转场动画。由 transition() 函数实例化并返回。

Encapsulates an animation transition. Instantiated and returned by the transition() function.

AnimationTriggerMetadata

包含一个动画触发器。由 trigger() 函数实例化并返回。

Contains an animation trigger. Instantiated and returned by the trigger() function.

类型

AUTO_STYLE

用于指定自动化样式。

Specifies automatic styling.

AnimateTimings

表示一个动画步骤中的动画时序参数。

Represents animation-step timing parameters for an animation step.