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
cancer
April 19, 2014
Technology
84
1
Share
JavaScriptでKeyframeAnimationを作ってみた
帰ってきたYokohama.js(#yjs20140419)でLTしたスライドです
cancer
April 19, 2014
More Decks by cancer
See All by cancer
JSXをモダンな感じで開発してみた
cancer
0
490
AngularJSで作ったアプリをReactで置き換えてみた
cancer
0
230
CSSスプライトを動的生成して快適ソシャゲ開発
cancer
1
270
第2回 Sass勉強会 in 社内
cancer
1
74
Other Decks in Technology
See All in Technology
JJUG CCC 2026 Spring AI時代の開発こそ標準化を武器に! ― 方式・プロセス・プラットフォームの標準化
s27watanabe
2
600
Diagnosing performance problems without the guesswork
elenatanasoiu
0
110
NFLコンペ2026 解法
lycorptech_jp
PRO
0
130
自称宇宙最速で不合格となったAIP-C01にリベンジを果たすべくAIで問題集アプリを作ってみた。
yama3133
0
230
JEP 522 Deep Dive - G1 GC同期コスト削減によるスループット向上を徹底検証&解説
tabatad
1
310
Generative UI × A2UI で AI エージェントを作った話 AI-DLC も使ってみた!
kmiya84377
1
270
はじめてのDatadog
kairim0
0
200
AI時代の私の技術インプットとアウトプット術
tonkotsuboy_com
15
7.6k
Datadog 認定試験の概要と対策
uechishingo
0
170
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.7k
A Harness for Behaviour: how to get AI to generate code that does what we intend, or "TDD in the age of AI"
xpmatteo
0
500
Spring AI × MCP 入門〜AIエージェントへのツール公開、境界設計から始める最小構成 〜
yuyamiyamoto
0
170
Featured
See All Featured
How GitHub (no longer) Works
holman
316
150k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Unsuck your backbone
ammeep
672
58k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Mind Mapping
helmedeiros
PRO
1
210
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Raft: Consensus for Rubyists
vanstee
141
7.5k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
330
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Crafting Experiences
bethany
1
160
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
370
Documentation Writing (for coders)
carmenintech
77
5.4k
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();
こんな感じで
ご清聴ありがとうございました