I have the following directive:
angular.module('mymod').directive("hideOnScroll", function($animate, $document) {
return function(scope, element, attrs) {
$document.bind('scroll', function () {
if ($document.scrollTop() > 80) {
console.log("this is fired1")
$animate.addClass(element, "fade");
} else {
console.log("this is fired2")
$animate.removeClass(element, "fade");
}
});
};
});
I have both "this is fired" messages in the log at some point
Plus, I have the following animation service:
angular.module('mymod').animation(".fade", function() {
console.log("this is never fired3")
return {
addClass: function(element, className) {
console.log("this is never fired4")
//TweenMax.to(element, 1, {opacity: 0});
},
removeClass: function(element, className) {
console.log("this is never fired5")
//TweenMax.to(element, 1, {opacity: 1});
}
};
});
None of it's console messages is fired. at all (3, 4 and 5). I checked if it's added to the browser, it is. And I have ngAnimate as a dependency
This is the element:
<div hide-on-scroll>Hello</div>
Edit: I can see in chrome's element inspector that the div doesn't get the new class after '$animate.addClass(element, "fade")' is fired
What am I missing?