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
JavaScriptでKeyframeAnimationを作ってみた
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
cancer
April 19, 2014
Technology
1
79
JavaScriptでKeyframeAnimationを作ってみた
帰ってきたYokohama.js(#yjs20140419)でLTしたスライドです
cancer
April 19, 2014
Tweet
Share
More Decks by cancer
See All by cancer
JSXをモダンな感じで開発してみた
cancer
0
480
AngularJSで作ったアプリをReactで置き換えてみた
cancer
0
230
CSSスプライトを動的生成して快適ソシャゲ開発
cancer
1
260
第2回 Sass勉強会 in 社内
cancer
1
71
Other Decks in Technology
See All in Technology
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
1.9k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.4k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
410
今日から始めるAmazon Bedrock AgentCore
har1101
4
410
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
180
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
650
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
410
AWS Network Firewall Proxyを触ってみた
nagisa53
1
230
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
360
Tebiki Engineering Team Deck
tebiki
0
24k
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
140
Music & Morning Musume
bryan
47
7.1k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
440
What's in a price? How to price your products and services
michaelherold
247
13k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
The agentic SEO stack - context over prompts
schlessera
0
640
Everyday Curiosity
cassininazir
0
130
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Design in an AI World
tapps
0
140
GraphQLとの向き合い方2022年版
quramy
50
14k
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();
こんな感じで
ご清聴ありがとうございました