Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CSS Animations vs WAAPI
Search
KeitaroOkamura
September 14, 2018
Programming
560
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS Animations vs WAAPI
KeitaroOkamura
September 14, 2018
Transcript
21 slides
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!
More Decks by KeitaroOkamura
See All by KeitaroOkamura
Suspenseのユースケースを探る
keitarookamura
1
330
ヤギでもわかるソフトウェアテスト
keitarookamura
0
150
ヤギでもわかるオブジェクト指向UIデザイン
keitarookamura
3
360
ヤギでもわかるGit入門
keitarookamura
1
300
ユースケースから考えるユーザビリティ
keitarookamura
1
240
サクッと簡単!お手軽 Scaffold
keitarookamura
1
340
自社サイトをPWA化した話
keitarookamura
0
140
マイクロインタラクションから考えるアニメーション
keitarookamura
1
310
Vue.js+AtomicDesign
keitarookamura
2
2.8k
Other Decks in Programming
See All in Programming
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
270
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
280
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
330
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
260
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
580
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
690
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
280
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
210
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
590
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
220
Featured
See All Featured
HDC tutorial
michielstock
2
1k
Raft: Consensus for Rubyists
vanstee
143
7.9k
Un-Boring Meetings
codingconduct
0
500
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
1k
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
So, you think you're a good person
axbom
PRO
2
2.3k
Making Projects Easy
brettharned
120
6.9k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
620
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
380