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
470
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
3.1k
第64回 HTML5とか勉強会 〜 Angular特集 〜
teyosh
0
610
Angular2を書くためのAngularJSの書き方
teyosh
3
8.3k
express 用 framework genieについて
teyosh
0
3k
はじめてのAngularJS
teyosh
1
880
Other Decks in Technology
See All in Technology
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
190
Flutterをカメラで動かしたかった話
sony
1
140
クラウドセキュリティ入門 ~安全なクラウド利用のための基礎知識~
lhazy
13
8.6k
TypeScript入門 2026
recruitengineers
PRO
3
570
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
290
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
230
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
160
【CEDEC2026】次世代デジタルカードゲームのサーバー設計と運用 〜『Shadowverse: Worlds Beyond』の舞台裏~
cygames
PRO
1
1.2k
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
MIRU 2026 チュートリアル
keisuke198619
0
900
ガバメントクラウドでのランサムウェア対策
techniczna
2
1.2k
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
400
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
Believing is Seeing
oripsolob
1
190
Navigating Team Friction
lara
192
16k
GraphQLとの向き合い方2022年版
quramy
50
15k
Become a Pro
speakerdeck
PRO
31
6.2k
Building an army of robots
kneath
306
46k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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