Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSS Animations vs WAAPI
Search
KeitaroOkamura
September 14, 2018
Programming
0
500
CSS Animations vs WAAPI
KeitaroOkamura
September 14, 2018
Tweet
Share
More Decks by KeitaroOkamura
See All by KeitaroOkamura
Suspenseのユースケースを探る
keitarookamura
1
280
ヤギでもわかるソフトウェアテスト
keitarookamura
0
120
ヤギでもわかるオブジェクト指向UIデザイン
keitarookamura
3
290
ヤギでもわかるGit入門
keitarookamura
1
240
ユースケースから考えるユーザビリティ
keitarookamura
1
210
サクッと簡単!お手軽 Scaffold
keitarookamura
1
280
自社サイトをPWA化した話
keitarookamura
0
110
マイクロインタラクションから考えるアニメーション
keitarookamura
1
260
Vue.js+AtomicDesign
keitarookamura
2
2.7k
Other Decks in Programming
See All in Programming
Zennの運営完全に理解した #完全に理解したTalk
wadayusuke
1
150
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
650
TypeScript だけを書いて Tauri でデスクトップアプリを作ろう / Tauri with only TypeScript
tris5572
2
540
テスト分析入門/Test Analysis Tutorial
goyoki
12
2.7k
TypeScript製IaCツールのAWS CDKが様々な言語で実装できる理由 ~他言語変換の仕組み~ / cdk-language-transformation
gotok365
7
400
Cursor Meetup Tokyo ゲノミクスとCursor: 進化と制約のあいだ
koido
2
610
がんばりすぎないコーディングルール運用術
tsukakei
1
200
Rethinking Data Access: The New httpResource in Angular
manfredsteyer
PRO
0
220
💎 My RubyKaigi Effect in 2025: Top Ruby Companies 🌐
yasulab
PRO
1
130
DevDay2025-OracleDatabase-kernel-addressing-history
oracle4engineer
PRO
7
1.7k
事業戦略を理解してソフトウェアを設計する
masuda220
PRO
15
4.1k
JSAI2025 RecSysChallenge2024 優勝報告
unonao
1
390
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
430
65k
The Power of CSS Pseudo Elements
geoffreycrofte
76
5.8k
Rails Girls Zürich Keynote
gr2m
94
13k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
106
19k
The Cult of Friendly URLs
andyhume
78
6.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
The Language of Interfaces
destraynor
158
25k
For a Future-Friendly Web
brad_frost
178
9.8k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Practical Orchestrator
shlominoach
188
11k
GraphQLとの向き合い方2022年版
quramy
46
14k
Transcript
CSS Animations vs WAAPI FukuokaJS #6 / 2018.09.13
PROFILE Keitaro Okamura karabiner.inc Frontend Engineer フロントエンドエンジニア0年生 @karaagekeitaroo
Web Animations API is 何? 新しい Web Animation Framework となる
JavaScriptのAPI 簡単に言うと、CSS Animation の keyframe 制御を JS から可能にしたようなもの ( W A A P I )
・ CSS animation、CSS transition ・ HTML5 Canvas ・ SVG animation
・ JS の DOM 操作で実装する animation … etc. Web Animation Patterns
・ CSS animation、CSS transition ・ HTML5 Canvas ・ SVG animation
・ JS の DOM 操作で実装する animation … etc. Web Animation Patterns WAAPI
1. Let’s create Animation! element.animate(keyframes, options); WAAPI を使用してアニメーションを作成するには、keyframes と options
の 2 つの引数をとる Element.animate() 関数を使用します。
1. Let’s create Animation! element.animate(keyframes, options); WAAPI を使用してアニメーションを作成するには、keyframes と options
の 2 つの引数をとる Element.animate() 関数を使用します。 Sample
2. keyframes → CSS Animations の場合 @keyframes zoom { 0%
{transform: none;} 50% {transform: scale(1.5);} 100% {transform: none;} } 0%, 100% にtransform: none;、 50% にtransform: scale(1.5);を設定しており、 それを直線的に動かしています。
2. keyframes → WAAPI の場合 const zoom = { transform:
['none', 'scale(1.5)', 'none'] } 1. 単一の keyframes Object を渡す 各キーは、CSS プロパティを表し、配列内の各値は、アニメー ションタイムライン上のポイントを表します。
2. keyframes → WAAPI の場合 const zoom = [ {
transform: 'none' }, { transform: 'scale(1.5)', offset: 0.5 }, { transform: 'none' } ] 2. 配列として書き出す 配列内の各アイテムは、タイムライン上のポイントを表し、その ポイントに適用される各 CSS プロパティと値を指定します。
3. options → WAAPI の場合 const zoomOptions = { duration:
2000, easing: 'linear', delay: 150, iterations: Infinity } animate() 関数に渡す2番目の引数は、 いくつかのオプションを持つ Object です。
3. options → CSS Animations の場合 .selector { animation-name: zoom;
animation-duration: 2s; animation-timing-function: linear; animation-delay: 0.15s; animation-iteration-count: infinite; } 上記のように animation プロパティを指定します。 animation: zoom 2s linear 0.15s infinite; 一括で指定する場合
3. options → CSS Animations の場合 No property Description 1
animation-name アニメーション名 2 animation-duration 実行時間 3 animation-timing-function 進行の度合い 4 animation-delay 開始時間 5 animation-iteration-count 繰り返し回数 6 animation-direction 再生方向 7 animation-fill-mode 再生前後の状態 8 animation-play-state 再生・停止
3. options → WAAPI の場合 No property Description 1 id
ユニークID 2 duration 実行時間 3 easing 進行の度合い 4 delay 開始時間 5 iteration 繰り返し回数 6 direction 再生方向 7 fill 再生前後の状態 8 endDelay 終了後に遅延する時間 9 iterationStart 開始する繰り返しポイント
4. controll const animation = element.animate(keyframes, options); animation.play(); // 再生
animation.pause(); // 一時停止 animation.reverse(); // 逆再生 animation.cancel(); // キャンセル animation.finish(); // 終了時点まで進める Animation メソッドを使うことでアニメーションの実行を controll することができます。
Support Firefox と Chrome でサポート 実際に使う場合は pollyfill ( web-animations-js )
が必須 https://caniuse.com/#feat=web-animation
Performance
DEMO
・ JS でサポートされている関数と組み合わせれる ・ DOM 操作で直接 HTML 要素をアニメーションできる ・ 止まったり再開したり、アニメーションの制御ができる
CSS Animations との比較
・ アニメーションロジックを JS で一元管理 ・ アニメーションの詳細に大きく依存 ( case by case
) まとめ CSS Animations UI 関連の 小さなアニメーション WAAPI 細かな controll を必要とするより 高度なアニメーション& エフェクト
THANKS!