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
460
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AngularJS DirectiveでAnimate
DirectiveでngAnimateを利用する方法を簡単に紹介
Tessei Yoshida
December 03, 2013
More Decks by Tessei Yoshida
See All by Tessei Yoshida
Angular Universalの歩き方
teyosh
0
230
型を使うと便利な開発
teyosh
0
3k
第64回 HTML5とか勉強会 〜 Angular特集 〜
teyosh
0
610
Angular2を書くためのAngularJSの書き方
teyosh
3
8.3k
express 用 framework genieについて
teyosh
0
3k
はじめてのAngularJS
teyosh
1
870
Other Decks in Technology
See All in Technology
そのドキュメント、自動化しませんか?
yuksew
1
400
複数プロダクト組織のAIネイティブ化における戦略 / AICon2026_kude
rakus_dev
0
290
Webアプリ認証の全体像 / The Big Picture of Web App Authentication
kitano_yuichi
1
410
DatabricksにおけるMCPソリューション
taka_aki
1
330
AICoEでAIネイティブ組織への進化
yukiogawa
0
210
「休む」重要さ
smt7174
5
1.5k
kaonavi Tech Night#1
kaonavi
0
140
Multicaで30個のミニプロジェクトをAIエージェント運用して見えてきたこと
eiei114
1
610
20260720_クラウド女子会×PyLadiesTokyoコラボ Amazon Bedrock ハンズオン用資料
yuuka51
1
110
アップデートで何が変わった?デモで学んで使いこなすIBM Bob2.0
muehara
0
220
SRENEXT_2026_Chairs__Talks_in_Tamachi.sre.pdf
srenext
1
130
ダッシュボード"開発"について 〜使われるダッシュボードのつくりかた〜
kimichan
0
170
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
400
Producing Creativity
orderedlist
PRO
348
40k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
190
HDC tutorial
michielstock
2
750
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
970
Leo the Paperboy
mayatellez
8
1.9k
How to Ace a Technical Interview
jacobian
281
24k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
220
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
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