2

First time trying to use angular animations and can't work out what I'm doing wrong.

I'm using AngularJS v1.3.0-build.2805 for both Angular itself and Animation module.

-1. Module is included

angular.module('profileApp', [
        'ngAnimate'
]);

-2. Defining styles in css

.fade-in{
  transition: 1s linear all;
  -webkit-transition: 1s linear all;
}

.fade-in.ng-enter,
.fade-in.ng-leave.ng-leave-active{
  opacity: 0;
}

.fade-in.ng-enter.ng-enter-active,
.fade-in.ng-leave{
  opacity: 1;
}

-3. Including class in ng-repeat

<a class="item fade-in" ng-repeat="item in collection" href="{{client.getPath('product/'+item.slug)}}">
    <div class="thumb">
        <img ng-src="{{item.images[0].imagename}}" alt="{{item.style_name}}">
    </div>
    <h3>{{item.style_name}}</h3>
</a>

What am I missing here??

Nitsan Baleli
  • 5,393
  • 3
  • 30
  • 52
markstewie
  • 9,237
  • 10
  • 50
  • 72
  • 2
    If you want to stagger the animation on load, then you have to push items into your array rather than assign the entire array to scope. Here is a plunker: http://plnkr.co/edit/ZceaB0Twapvqek37NnJp?p=preview – Michael Kang Jun 25 '14 at 04:54

1 Answers1

4

Here's a great tutorial about staggering animation in angularjs, by yearofmoo

as stated in the comments to your question,by pixelbits:

If you want to stagger the animation on load, then you have to push items into your array rather than assign the entire array to scope.

he also provided a nice plunkr that shows how to properly make the animation.

list.html

<div id="list-wrap">
    <ul id="page-list">
        <li class="page-list-item" ng-repeat="item in items" ng-click="tapHandle(this)">
            <span class="page-list-text">{{ item }}</span>
        </li>
    </ul>
</div>

style.css:

.page-list-item.ng-enter-stagger,
.page-list-item.ng-leave-stagger {
    -webkit-transition-delay: 0.2s;
    -moz-transition-delay: 0.2s;
    -ms-transition-delay: 0.2s;
    -o-transition-delay: 0.2s;
    transition-delay: 0.2s;
    -webkit-transition-duration: 0;
    -moz-transition-duration: 0;
    -ms-transition-duration: 0;
    -o-transition-duration: 0;
    transition-duration: 0;
}

.page-list-item.ng-enter {
    -webkit-transition: 0.2s linear all;
    -moz-transition: 0.2s linear all;
    -ms-transition: 0.2s linear all;
    -o-transition: 0.2s linear all;
    transition: 0.2s linear all;
    -ms-opacity: 0;
    opacity: 0;
}


.page-list-item.ng-enter.ng-enter-active {
    -ms-opacity: 1;
    opacity: 1;
}

.page-list-item.ng-leave {
    -webkit-transition: 0.2s linear all;
    -moz-transition: 0.2s linear all;
    -ms-transition: 0.2s linear all;
    -o-transition: 0.2s linear all;
    transition: 0.2s linear all;
    -ms-opacity: 1;
    opacity: 1;
}

.page-list-item.ng-leave.ng-leave-active {
    -ms-opacity: 0;
    opacity: 0;
}
Dave Boster
  • 310
  • 4
  • 10
Nitsan Baleli
  • 5,393
  • 3
  • 30
  • 52