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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Tessei Yoshida
December 03, 2013
Technology
460
2
Share
AngularJS DirectiveでAnimate
DirectiveでngAnimateを利用する方法を簡単に紹介
Tessei Yoshida
December 03, 2013
More Decks by Tessei Yoshida
See All by Tessei Yoshida
Angular Universalの歩き方
teyosh
0
210
型を使うと便利な開発
teyosh
0
3k
第64回 HTML5とか勉強会 〜 Angular特集 〜
teyosh
0
600
Angular2を書くためのAngularJSの書き方
teyosh
3
8.3k
express 用 framework genieについて
teyosh
0
3k
はじめてのAngularJS
teyosh
1
860
Other Decks in Technology
See All in Technology
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
200
[Scram Fest Niigata2026]Quality as Code〜AIにQAの思考を再現させる試み〜
masamiyajiri
1
310
ボトムアップ限界を越える - 20チームを束る "Drive Map" / Beyond Bottom-Up: A 'Drive Map' for 20 Teams
kaonavi
0
180
【技術書典20】OpenFOAM(自宅で深める流体解析)流れと熱移動(2)
kamakiri1225
0
390
大学職員のための生成AI最前線 :最前線を、AIガバナンスとして読み直すためのTips
gmoriki
2
4k
2026-05-14 要件定義からソース管理まで!IBM Bob基礎ハンズオン
yutanonaka
0
140
Gaussian Splattingの表現力を拡張する — 高周波再構成とインタラクションへのアプローチ —
gpuunite_official
0
140
マンション備え付けのネットワークとLTE回線を組み合わせた ネットワークの安定化の考案
harutiro
1
120
鹿野さんに聞く!CSSの最新トレンド Ver.2026
tonkotsuboy_com
6
2.9k
データモデリング通り #5オンライン勉強会: AIに『ビジネスの文脈』を教え込むデータモデリング
datayokocho
0
250
Digital Independence: Why, When and How
wannesrams
0
310
SLI/SLO、「完全に理解した」から「チョットデキル」へ
maruloop
3
400
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
0
340
The untapped power of vector embeddings
frankvandijk
2
1.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
WENDY [Excerpt]
tessaabrams
10
37k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Automating Front-end Workflow
addyosmani
1370
200k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
140
Unsuck your backbone
ammeep
672
58k
How to train your dragon (web standard)
notwaldorf
97
6.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
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