animate
定义一个动画步骤,它把一些样式信息和时序信息组合在一起。
Defines an animation step that combines styling information with timing information.
animate(timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata = null): AnimationAnimateMetadata
参数
timings | string | number | 为父动画设置 Sets
比如,字符串 "1s 100ms ease-out" 指定了一个 1000 毫秒的持续时间,一个 100 毫秒的延迟和一个 "ease-out" 缓动效果,它会快结束时减速。 For example, the string "1s 100ms ease-out" specifies a duration of 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style, which decelerates near the end of the duration. |
styles | AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | 为父动画设置动画样式。 调用 Sets AnimationStyles for the parent animation. A function call to either 可选. 默认值是 |
返回值
一个用于封装动画步骤的对象。
AnimationAnimateMetadata: An object that encapsulates the animation step.
使用说明
在一个 sequence()(动画序列)、group()(动画分组)或 transition()(转场动画)中调用本函数, 以定义一个动画步骤,来把指定的样式数据在父动画上播放指定的时长。
Call within an animation sequence(), group(), or transition() call to specify an animation step that applies given style data to the parent animation for a given amount of time.
语法范例
Syntax Examples
时序范例
Timing examples
下面的例子展示了各种 timings(时序)规范。
The following examples show various timings specifications.
animate(500):持续 500 毫秒。animate(500): Duration is 500 milliseconds.animate("1s"):持续 1000 毫秒。animate("1s"): Duration is 1000 milliseconds.animate("100ms 0.5s"):持续 100 毫秒,延迟 500 毫秒。animate("100ms 0.5s"): Duration is 100 milliseconds, delay is 500 milliseconds.animate("5s ease-in"):持续 5000 毫秒,缓动进入(ease-in)。animate("5s ease-in"): Duration is 5000 milliseconds, easing in.animate("5s 10ms cubic-bezier(.17,.67,.88,.1)"):持续 5000 毫秒,延迟 10 毫秒,基于一条 Bezier 曲线进行缓动。animate("5s 10ms cubic-bezier(.17,.67,.88,.1)"): Duration is 5000 milliseconds, delay is 10 milliseconds, easing according to a bezier curve.
样式范例
Style examples
下面的例子调用 style() 来设置单个的 CSS 样式。
The following example calls style() to set a single CSS style.
animate(500, style({ background: "red" }))
下面的例子调用 keyframes() 来为各个相邻的关键帧分别设置 CSS 样式。
The following example calls keyframes() to set a CSS style to different values for successive keyframes.
animate(500, keyframes(
[
style({ background: "blue" })),
style({ background: "red" }))
])