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
AngularJS DirectiveでAnimate
Search
Tessei Yoshida
December 03, 2013
Technology
2
430
AngularJS DirectiveでAnimate
DirectiveでngAnimateを利用する方法を簡単に紹介
Tessei Yoshida
December 03, 2013
Tweet
Share
More Decks by Tessei Yoshida
See All by Tessei Yoshida
Angular Universalの歩き方
teyosh
0
150
型を使うと便利な開発
teyosh
0
2.6k
第64回 HTML5とか勉強会 〜 Angular特集 〜
teyosh
0
500
Angular2を書くためのAngularJSの書き方
teyosh
3
7.9k
express 用 framework genieについて
teyosh
0
2.7k
はじめてのAngularJS
teyosh
1
760
Other Decks in Technology
See All in Technology
最近たまに見かけるTiDBってなんだ? - Findy
pingcap0315
2
570
NLP2024 参加報告LT ~RAGの生成評価と懇親戦略~ / nlp2024_attendee_presentation_LT_masuda
taro_masuda
1
200
Tebiki株式会社 エンジニア採用資料
tebiki
0
4.1k
PHP"オレ"カンファレンスの告知
ysknsid25
0
360
シン・Kafka / shin-kafka
oracle4engineer
PRO
7
2.7k
ユーザーストーリーのレビューを自動化したみたの
bun913
1
310
入社後初めてのタスクでk8sアップグレードした話.pdf
kkato1
1
380
PHPカンファレンス小田原2024
ysknsid25
3
660
Oracle Cloud Infrastructure:2024年4月度サービス・アップデート
oracle4engineer
PRO
1
110
SPI原点回帰論:事業課題とFour Keysの結節点を見出す実践的ソフトウェアプロセス改善 / DevOpsDays Tokyo 2024
visional_engineering_and_design
4
1.5k
AWS を使う上で知っておきたいオンプレミス知識/aws-on-premise-essentials
emiki
1
4.2k
スタートアップの技術顧問を3年間続けて発生した事と気付き
biwakonbu
0
150
Featured
See All Featured
The Language of Interfaces
destraynor
151
23k
The Art of Programming - Codeland 2020
erikaheidi
41
12k
What the flash - Photography Introduction
edds
64
11k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
GraphQLの誤解/rethinking-graphql
sonatard
50
9.2k
Happy Clients
brianwarren
91
6.4k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
The Cult of Friendly URLs
andyhume
74
5.7k
We Have a Design System, Now What?
morganepeng
42
6.7k
Statistics for Hackers
jakevdp
789
220k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
154
14k
Transcript
AngularJS LT DirectiveにngAnimateをつけよう
自己紹介 吉田徹生(よしだてっせい) @teyosh
AngularJS使ってますか? 11月に1.2が公開されました。
1.2 追加で待望のngAnimateが公 式モジュールとして追加されま した。
Extrasのディレクトリ
ngAnimateの基本 ngAnimateを読み込む angular.module("mainAnime", ["ngAnimate"])
用意してされているng-* ng-repeat ng-show ng-hide ng-if ng-view ng-include
例 : ng-repeat ng-repeat対象の配列に追加削除した際にアニ メーションを付ける <div class=”smain-animation” ng-repeat=”item in items
track by $index”>{{item}}</div>
CSS3でアニメーション .smain-animation {left : 100px; position:relative; -webkit-transition:0.5s linear all;} .smain-animation.ng-enter,
.smain-animation.ng-leave.ng-leave-active {left:-100px;} .smain-animation.ng-enter.ng-enter-active, .smain-animation.ng-leave { left:100px; }
JavaScriptでアニメーション .animation('.main-animation', function(){ return { enter: function(element, done){ $(element).css({left :
-100}); $(element).animate({left : 50},done); }, leave : function(element, done){ $(element).animate({left : 0},done); } }; })
Directiveにアニメーション もちろん自作のDirectiveにもア ニメーションを設定できます。
$animateで設定 $animateで実行されます。 $animate.enter(element, parent, after, callback); $animate.leave(element, callback); $animate.move(element, parent,
after, callback); $animate.addClass(element, className, callback); $animate.removeClass(element, className, callback);
こんなかんじでDirective .directive("mainAnimation", ["$animate", function($animate){ return { restrict: "A", template: "<button
ng-click='enteranime()'>enter</button><button ng- click='leaveanime()'>leave</button>", link: function(scope, element, attr){ scope.spans = [];
続き enter追加 scope.enteranime = function(){ var $test = angular.element("<div class=\"main-animation\">test</div>");
var $after = angular.element(element.children()[element.children().length- 1]); $animate.enter($test, element, $after, function(){ scope.spans.push($test); }); };
続き leave追加 scope.leaveanime = function(){ if(scope.spans.length){ $animate.leave(scope.spans.pop()); } }; }
}; }])
出来たのはこちら http://plnkr. co/edit/MlEVCWFvEWWAMdZkPcSV? p=preview