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
JavaScriptでKeyframeAnimationを作ってみた
Search
cancer
April 19, 2014
Technology
91
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JavaScriptでKeyframeAnimationを作ってみた
帰ってきたYokohama.js(#yjs20140419)でLTしたスライドです
cancer
April 19, 2014
More Decks by cancer
See All by cancer
JSXをモダンな感じで開発してみた
cancer
0
500
AngularJSで作ったアプリをReactで置き換えてみた
cancer
0
240
CSSスプライトを動的生成して快適ソシャゲ開発
cancer
1
280
第2回 Sass勉強会 in 社内
cancer
1
86
Other Decks in Technology
See All in Technology
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
600
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
160
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
430
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
160
大型犬好きによるPugの紹介
yamanoku
1
160
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
280
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
140
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
今さら理解するウェブフォントver.2026
takanorip
3
840
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
270
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
How to Talk to Developers About Accessibility
jct
2
580
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Embracing the Ebb and Flow
colly
88
5.2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Facilitating Awesome Meetings
lara
57
7.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
How to build a perfect <img>
jonoalderson
1
6.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Transcript
帰ってきたYokohama.js (#yjs20140419) JavaScript で KeyframeAnimation を 作ってみた
自己紹介 宇野 陽太( ) @cancer6 株式会社モバイルファクトリー というところで フロントエンドエンジニアやってます 最近はBackbone /
Marionette / AngularJS あたりを触ったり CSS 書いたりなど
CSS Animation
CSS Animation CSS にkeyframe 書いて... アニメー ション用のclass を作ってプロパティ書いて... JS からclass
の操作して... ...
めんどくさい
どうせJS 使うなら全部JS で やってしまおう
css-animations.js https://github.com/jlongster/css-animations.js DOM からCSS にアクセスして色々 やってくれる CSS ファイルで定義したkeyframe を取ってきたり JavaScript
から動的にkeyframe を生成したり オブジェクトでkeyframe のプロパティを渡してあげる var anim1 = CSSAnimations.get("anim1"); var anim2 = CSSAnimations.create("anim2", { "0%": { "background-color": "red" }, "100%": { "background-color": "blue" }
css-animations.js ベンダー プレフィックスが必要なプロパティの記述が冗長 transform 系のプロパティも冗長になりがち アニメー ションのプロパティ(animation-name/animation- duration など) は別途DOM
の操作が必要 var anim = CSSAnimations.create("anim", { "0%": { opacity: "0.5", border-radius: "0" "-webkit-border-radius": "0" transform: "translate(0, 0) rotate(90deg) scale(1)" "-webkit-transform": "translate(0, 0) rotate(90deg) scale(1)" }, "100%": { opacity: "1", border-radius: "5px" "-webkit-border-radius": "5px" transform: "translate(100px, 50px) rotate(180deg) scale(2)" "-webkit-transform": "translate(100px, 50px) rotate(180deg) scale(2)" } $("#animation").css({ "animation-name": "anim", "animation-duration": "5s" "animation-timing-function": "linear" "animation-delay": "1s" "animation-fill-mode": "both"
まだめんどくさい
keyframe-animations.js カッコカリ https://github.com/cancer/keyframe-animations.js ( さっき) つくりました No more ベンダー プレフィックス
transform 系も見やすく アニメー ションのプロパティも一緒に設定できます var animation = keyframeAnimation.setup({ name: "anim", keyframe: { "0%": { opacity: "0.5", borderRadius: "0", translate: "0 0", rotate: "90deg", scale: "1" }, "100%": { opacity: "1", borderRadius: "5px", translate: "100px 50px", rotate: "180deg", scale: "2" } }, animation: { duration: "5s",
keyframe-animations.js カッコカリ アニメー ションの実行/ 停止もかんたん animationEnd で何かしたいとかもできます // アニメーション実行 animation.animate($("#animation"));
// アニメーション停止 animation.freeze(); // animationEndで何か実行したい animation.animate($("#animation"), function($element){ // アニメーションが終わったら要素を非表示にする $element.hide() });
keyframe-animations.js カッコカリ アニメー ションのライブラリを作ったりすると捗るはず var animationLibrary = new AnimationLibrary(); animationLibrary.setupModalAnimation();
こんな感じで
ご清聴ありがとうございました