Responsive Web Design
  • Responsive Web Design 課程
  • 1 簡介
    • 1.1 講者簡介
    • 1.2 課程簡介
  • 2 版面概念解析
  • 3 Media Query
    • 3.1 媒體類型 Media Type
    • 3.2 媒體描述 Media Features
    • 3.3 練習
  • 4 Viewport
    • 4.1 Viewport 定義
    • 4.2 HTML Viewport Meta
  • 5 Bootstrap Grid System
    • 5.1 載入 Grid 相關 CSS
    • 5.2 Grid System
    • 5.3 breakpoint 練習
  • 6 Transition 轉場效果
    • 6.1 第一個 transition
    • 6.2 transition-property
    • 6.3 transition-duration
    • 6.4 transition-timing-function
    • 6.5 transition-delay
    • 6.6 transition 簡寫
    • 6.7 練習
  • 7 Grid 排版模式
    • 7.1 基本觀念及術語
    • 7.2 Grid Container
    • 7.3 Grid Items
    • 7.4 練習
  • 8 Animation 動畫效果
    • 8.1 第一個 animation
    • 8.2 關於 keyframes
    • 8.3 相同元素套用多個 animation
    • 8.4 animation-iteration-count
    • 8.5 animation-direction
    • 8.6 animation-delay
    • 8.7 animation-fill-mode
    • 8.8 animation-play-state
    • 8.9 animation-timing-function
    • 8.10 animation 簡寫
    • 8.11 練習
  • 9 練習
  • 10 RWD 作業
  • 11 手機連本機端網站
  • 12 參考資料
  • 13 補充:AOS
Powered by GitBook
On this page
  • animation-timing-function 說明
  • 1 ease、linear
  • 2 ease-in、ease-out、ease-in-out
  • 3 cubic-bezier(x1, y1, x2, y2) 函式
  • 4 steps(int, start | end) 函式
  1. 8 Animation 動畫效果

8.9 animation-timing-function

animation-timing-function 說明

透過使用 animation-timing-function ,可以控制動畫效果的速度曲線,背後的原理是 cubic-bezier。

animation-timing-function 有七種模式:

  • ease:這是預設。相當於 cubic-bezier(.25, .1, .25, 1)

  • linear:相當於 cubic-bezier(0, 0, 1, 1)

  • ease-in:相當於 cubic-bezier(.42, 0, 1, 1)

  • ease-out:相當於 cubic-bezier(0, 0, .58, 1)

  • ease-in-out:相當於 cubic-bezier(.42, 0, .58, 1)

  • cubic-bezier(n, n, n, n)

  • steps(int, start | end)

1 ease、linear

  • ease:低速 → 加快 → 減速至結束。這是預設值。

  • linear:速度保持一致。

示意圖:

例:(一個元素從左邊跑到右邊)

2 ease-in、ease-out、ease-in-out

  • ease-in:以低速開始。

  • ease-out:以低速結束。

  • ease-in-out:以低速開始,也以低速結束。

示意圖:

例:

3 cubic-bezier(x1, y1, x2, y2) 函式

像上述的 ease(預設)、linear、ease-in、ease-out、ease-in-out 等,都是別名,其實背後都是透過 cubic-bezier() 函式來達成。

這裡有兩個不錯的網站:

例如 linear,我們其實也可以用以下來代替(相當於 cubic-bezier(0, 0, 1, 1)):

animation-timing-function: cubic-bezier(0, 0, 1, 1);

所以透過 cubic-bezier() 函式 ,可以自訂任何想要的動畫執行速度快慢。

4 steps(int, start | end) 函式

這會以跳躍式的方式來執行,第一個參數(steps)是一個正整數,表示有幾個間隔;而第二個參數(position)可設定 start 或 end(若沒有提供的話,預設是 end ),來看看範例來瞭解其中差異:

想成如果是 start,就是一開始就要跳。

示意圖:

例:

Previous8.8 animation-play-stateNext8.10 animation 簡寫

Last updated 1 year ago

:自行建立曲線,來創造動畫不同的執行速度。

:列出很多已經建好的函式形式,可以直接套用。

自訂曲線
Easing Functions