I'm trying to animate the logo on my app home screen so after 2 seconds the logo fades in and begins a looped animation after the fade is complete to bob up and down.
I've thought of adding a timeout in the controller like this:
$timeout(function(){
$scope.animationClass = 'animateOn';
});
And then trigger the animation when the class is added to the dom.
However I think it may be best to put this animation delay code in a directive as it will separate the code and make it reusable.
I just wondered if there's an easier way of doing this as I'm new to animating with Angular JS.
EDIT:
I've made a directive to add a class after a delay. This works great, but is there an easier alternative? See below:
.directive('animationDelay', function($animate,$timeout) {
return function(scope, elem, attr) {
$timeout(function() {
$animate.addClass(elem, 'my-animate');
}, attr.animationDelay);
};
});
Called by using:
<img animation-delay="3000" id="mainLogo" src="img/logo.svg" class="homeLogo" />
Thanks