.directive('slideUp',
function(){
return {
link: function(scope, element, attrs) {
element.slideUp(attrs.slideUp)
}
}
}
)
This is an over simplified version. It will perform the animation as soon as the element is loaded...
You probably need more some specific timing, but the directive is your friend for jQuery code. If you want it to wait until some moment, like when it gets displayed, and a more generic directive for either direction, you can do something like this:
<div slide-animate="fast" direction="down">Hello World</div>
.directive('slideAnimate',
function(){
return {
link: function(scope, element, attrs) {
scope.$watch(
function(){ return
element.is(':visible') }, //watches for element to become visible
function(isShown){
if (isShown){
switch (attrs.direction){
case 'up': element.slideUp(attrs.slideAnimate); break;
case 'down': element.slideDown(attrs.slideAnimate); break;
break;
}
}
)
}
}
}
)