angularAnimate

angular 1.5.8

by jiexishede

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-animate.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.0/animate.css">
<body  ng-app="app" ng-controller="myctrl">
<div ng-if="onOff" class="fold-animation">
    This element will go BOOM
</div>
<button ng-click="onOff = true">Fold In</button>
</body>

CSS

.red { background:red; color: purple}
        .large-text { font-size:20px; }

        /* we can also use a keyframe animation and $animateCss will make it work alongside the transition */

        .pulse-twice {
            animation: 0.5s pulse linear 2;
            -webkit-animation: 0.5s pulse linear 2;
        }

        @keyframes pulse {
            from { transform: scale(0.5); }
            to { transform: scale(1.5); }
        }

        @-webkit-keyframes pulse {
            from { -webkit-transform: scale(0.5); }
            to { -webkit-transform: scale(1.5); }
        }

JavaScript

var app = angular.module('app', ['ngAnimate']);
   angular.module('app', ['ngAnimate']).animation('.fold-animation', ['$animateCss', function($animateCss) {
            return {
                enter: function(element, doneFn) {
                    var height = element[0].offsetHeight;
                    return $animateCss(element, {
                        addClass: 'red large-text pulse-twice',
                        easing: 'ease-out',
                        from: { height:'0px' },
                        to: { height:height + 'px' },
                        duration: 10 // one second
                    });
                }
            }
        }]);
   angular.module('app', ['ngAnimate']).controller('myctrl', function ($scope) {
      
    })