I can't figure out why the following animation doesn't work as it should:
app.directive('openMenu', ['$animate', '$timeout', function($animate, $timeout) {
return {
link: function(scope, elem) {
elem.bind('click', function() {
if(elem.is(':animated'))
return;
$timeout(function() {
$animate.addClass(elem, 'see');
}, 0);
});
}
}
}]);
And in this one the animation doesn't work at all (and class is not added either):
app.directive('openMenu', ['$animate', function($animate) {
return {
link: function(scope, elem) {
elem.bind('click', function() {
if(elem.is(':animated'))
return;
$animate.addClass(elem, 'see');
});
}
}
}]);
In the second code snippet I only removed $timeout
, which is 0, I tried to use self-firing functions to check - animating works only when I am using timeouts. Can someone explain me why?
middle {
margin-left: 0;
}
middle.see {
margin-left: 270px;
}
.middle.see-add {
-webkit-transition: margin-left 300ms;
-moz-transition: margin-left 300ms;
-ms-transition: margin-left 300ms;
-o-transition: margin-left 300ms;
transition: margin-left 300ms;
margin-left: 0;
}
.middle.see-add.see-add-active {
margin-left: 270px;
}
Here is the markup:
<div class="middle" open-menu></div>