Skip to content

Commit 6d8da32

Browse files
author
Dean Sofer
committed
Added ui-animate demo
1 parent 0dd4975 commit 6d8da32

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

css/app.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ section {
2525
background-position: -48px -96px;
2626
}
2727

28+
/*** Animate ***/
29+
#directives-animate .animations {
30+
list-style: none;
31+
padding: 0;
32+
margin: 10px 0;
33+
}
34+
#directives-animate .animations li {
35+
transition: all 0.5s ease;
36+
-o-transition: all 0.5s ease;
37+
-moz-transition: all 0.5s ease;
38+
-webkit-transition: all 0.5s ease;
39+
background: lightblue;
40+
max-height: 50px;
41+
overflow: hidden;
42+
padding: 5px;
43+
}
44+
#directives-animate .animations li.ui-animate {
45+
opacity: 0;
46+
max-height: 0;
47+
padding: 0 5px;
48+
}
49+
2850
/*** If ***/
2951
#directives-if ul.piped-list {
3052
padding: 0;

index.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,55 @@ <h3>How?</h3>
370370
&lt;script&gt;
371371
$scope.resetModal = &#x27;Hover over me&#x27;;
372372
&lt;/script&gt;
373+
</pre>
374+
</div>
375+
</div>
376+
</section>
377+
378+
<section id="directives-animate" ng-controller="AnimateCtrl">
379+
<div class="page-header">
380+
<h1>Animate</h1>
381+
</div>
382+
<div class="row">
383+
<div class="span6">
384+
<h3>What?</h3>
385+
<p>Transition the injection of new DOM elements.</p>
386+
<p class="alert">Support will later be added for transitioning the removal of DOM elements due to the complexity of this task.</p>
387+
<a class="btn" ng-click="items.push(true)"><i class="icon-plus"></i> Add Item</a>
388+
<ul class="animations">
389+
<li ng-repeat="item in items" ui-animate>Item #{{$index+1}}</li>
390+
</ul>
391+
<pre>$scope.items: {{items}}</pre>
392+
<h3>Why?</h3>
393+
<p>People have been asking for a way to animate the addition and removal of DOM elements. This is a simple way of doing it using CSS3 transitions. A 'hidden' transitionable class (that doesn't use <code>dislay:none</code>) is attached to the node before it's injected and then immediately removed after.</p>
394+
</div>
395+
<div class="span6">
396+
<h3>How?</h3>
397+
<p>You can pass a string to use as the class to transition to / from (such as <code>ui-hide</code>). An object can also be passed with support for a <code>class</code> attribute. More options will be supported with future updates.</p>
398+
<pre class="prettyprint linenums" ng-non-bindable>
399+
&lt;a ng-click=&quot;items.push(true)&quot;&gt;Add Item&lt;/a&gt;
400+
&lt;ul&gt;
401+
&lt;li ng-repeat=&quot;item in items&quot; ui-animate&gt;{{item}}&lt;/li&gt;
402+
&lt;/ul&gt;
403+
404+
&lt;style&gt;
405+
li {
406+
transition: all 0.5s ease;
407+
-o-transition: all 0.5s ease;
408+
-moz-transition: all 0.5s ease;
409+
-webkit-transition: all 0.5s ease;
410+
background: lightblue;
411+
max-height: 50px; /* 1000px works too */
412+
overflow: hidden;
413+
padding: 5px;
414+
}
415+
/* The 'hidden' state to transition from & to */
416+
li.ui-animate {
417+
opacity: 0;
418+
max-height: 0;
419+
padding: 0 5px;
420+
}
421+
&lt;/style&gt;
373422
</pre>
374423
</div>
375424
</div>

js/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ function UniqueCtrl($scope) {
7676
];
7777
}
7878

79+
function AnimateCtrl($scope) {
80+
$scope.items = [];
81+
}
82+
7983
function CurrencyCtrl($scope) {
8084
$scope.nums = {
8185
pos : 1000,

0 commit comments

Comments
 (0)