目标 Objective

内容 Content

  1. Lorem ipsum dolor sit.
  2. Aperiam beatae odit consectetur?
  3. Consectetur amet repellat error?
  4. Cum, delectus deserunt? Magni.
  5. Atque illum reiciendis ut.

回顾 Review

引言 Introduction

思维导图

过渡动画 Transition

动画使用 Usage

过渡属性
item desc
property 元素参与过渡的属性,必须是 数值型 的属性
通常指定为 all;建议 指定为特定属性
duration 过渡持续时间,单位秒 s 或毫秒 ms,必选参数,且必须是第一个时间参数;第二个时间参数是延迟时间
UI界面的过渡通常不超过 0.4s
timing-function 时间函数,过渡的效果/方式
默认是 ease
delay 过渡延迟时间,必须是第二个时间参数;第一个时间参数是过渡时间
时间函数 timing-function
item desc
linear 以相同速度开始到结束( cubic-bezier(0, 0, 1, 1) )
ease 默认;开始慢,然后快,慢下来,结束时非常慢( cubic-bezier(0.25, 0.1, 0.25, 1))
ease-in 开始慢,结束快( cubic-bezier(0.42,0,1,1)
ease-out 开始快,结束慢( cubic-bezier(0,0,0.58,1)
ease-in-out 中间快,两边慢( cubic-bezier(0.42,0,0.58,1)
cubic-bezier(n,n,n,n) 在 cubic-bezier 函数中定义自己的值
steps() 步进方式变换,见后续内容

步进动画 Steps()

steps(number_of_steps,direction)

帧动画 Animation

动画状态 State

动画定义 @keyframes

动画使用 Usage

动画属性
item desc
name 动画名称
duration 动画持续时间 - length of time that an animation takes to complete one cycle
单位秒 s 或毫秒 ms
必须是正值或0 - must be positive or zero
必须指定单位 - unit is required
timing-function 动画方式;见下表
delay 动画延迟时间,必须是第2个时间参数
正值 positive value:推迟
负值 negative value:提前
iteration-count 动画播放次数
数值:默认1
infinite:无穷;重复播放
direction 动画方向
alternate:
reverse:反向播放
alternate-reverse:先反向播放,再正向播放
fill-mode 动画开始和结束时如何应用状态/样式 - applies styles to its target before and after its execution
none:不指定任何样式;从元素初始状态开始,结束后返回初始状态;默认值
backwards:动画开始时,从第一个关键帧开始;如果有延迟,将始终保持在当前状态
forwards:动画结束时,保持在最后一个关键帧 - retain the computed values set by the last keyframe;特别适合多个有延迟的动画
both:从第一个关键帧开始,结束时保持在最后一个关键帧;不会返回初始状态
animation-play-state 动画状态 - whether an animation is running or paused
paused:暂停状态 - currently paused
running:播放状态 - currently playing
可以通过 :hover 或 JavaScript 来控制动画的播放状态
animation-timeline 动画时间线
动画方式 animation-timing-function
item desc
ease 默认。动画以低速开始,然后加快,在结束前变慢
linear 动画从头到尾的速度是相同的
ease-in 动画以低速开始
ease-out 动画以低速结束
ease-in-out 动画以低速开始和结束
cubic-bezier(n,n,n,n) 使用 cubic-bezier 函数定义过程
steps() 步进动画方式;见后续内容

步进动画 Steps()

steps(number_of_steps,direction)

时间轴动画 Timeline

时间轴动画常用属性
item desc
animation-timeline none | auto | scroll() | view()
animation-range-start 动画开始范围;默认 0
animation-range-end 动画结束范围;默认 100%
animation-range 复合属性;动画范围;默认 0 100%
  1. view(start,end)
    • 元素在屏幕/视口可见时才触发 - animation happens only when the element is visible on the screen
    • 元素进入视口,动画开始播放
    • 元素到达视口顶部,动画结束播放
    • start: Inward offset from beginning of the scrollport. default 0
    • end: Inward offset from end of the scrollport. default 0
    • 通常取值 view(50% 10%)
    定制动画视口大小
  2. scroll()

初始化 Initialization

练习 Drill

小结 Summary

作业 Homework

参考 Reference

  1. 过渡动画 transition
  2. 帧动画 animation
  3. animation-timeline
  4. animation-range
  5. view()
  6. Scroll Reveal
  7. GASP