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
83
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
73
Other Decks in Technology
See All in Technology
データモデリング通り #5オンライン勉強会: AIに『ビジネスの文脈』を教え込むデータモデリング
datayokocho
0
180
「強制アップデート」か「チームの自律」か?エンタープライズが辿り着いたプラットフォームのハイブリッド運用/cloudnative-kaigi-hybrid-platform-operations
mhrtech
0
120
AIが自律的に働く時代へ Amazon Quick で実現するAIエージェント紹介
koheiyoshikawa
0
190
拝啓、あの夏の僕へ〜あなたも知っているApp Runnerの世界〜
news_it_enj
0
220
世界の中心でApp Runnerを叫ぶ FINAL
tsukuboshi
0
250
AIエージェントの支払い基盤 AgentCore Payments概要
kmiya84377
1
130
多角的な視点から見たAGI
terisuke
0
120
Modernizing Your HCL Connections Experience: Visual Report to chain, Profile Enhancements, and AI Integration
wannesrams
0
290
AWS Transform CustomでIaCコードを自由自在に変換しよう
duelist2020jp
0
250
[Oracle TechNight#99] 生成AI時代のAI/ML入門 ~ AIとオラクルデータベースの関係 (後半)
oracle4engineer
PRO
3
240
Agents CLI と Gemini Enterprise Agent Platform で マルチエージェント開発が楽しくなる!
kaz1437
0
260
会社説明資料|株式会社ギークプラス ソフトウェア事業部
geekplus_tech
0
190
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
0
910
Optimizing for Happiness
mojombo
378
71k
Agile that works and the tools we love
rasmusluckow
331
21k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Leo the Paperboy
mayatellez
7
1.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
190
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
So, you think you're a good person
axbom
PRO
2
2k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
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();
こんな感じで
ご清聴ありがとうございました