Also read: http://www.cnblogs.com/Answer1215/p/3941966.html

Using ngAnimate:

//!annotate="YourApp" Your AngularJS Module|Replace this or ngModule with the module that you used to define your application.
var ngModule = angular.module('YourApp', ['ngAnimate']);
ngModule.animation('.my-crazy-animation', function() {
return {
enter: function(element, done) {
//run the animation here and call done when the animation is complete
return function(cancelled) {
//this (optional) function will be called when the animation
//completes or when the animation is cancelled (the cancelled
//flag will be set to true if cancelled).
};
},
leave: function(element, done) { },
move: function(element, done) { }, //animation that can be triggered before the class is added
beforeAddClass: function(element, className, done) { }, //animation that can be triggered after the class is added
addClass: function(element, className, done) { }, //animation that can be triggered before the class is removed
beforeRemoveClass: function(element, className, done) { }, //animation that can be triggered after the class is removed
removeClass: function(element, className, done) { }
};
});

Example:

js:

angular.module('categories', [
'eggly.models.categories',
'ngAnimate'
]) .config(function ($stateProvider) {
$stateProvider
.state('eggly.categories', {
url: '/',
views: {
'categories@': {
controller: 'CategoriesController',
templateUrl: 'app/categories/categories.tmpl.html'
},
'bookmarks@': {
controller: 'BookmarksController',
templateUrl: 'app/categories/bookmarks/bookmarks.tmpl.html'
}
}
});
}) .controller('CategoriesController', function ($scope) { }) .directive('menuItem', function(){
var controller = function($scope){
$scope.mouse_over = false;
}; return {
scope: true,
controller: controller
}
}) .animation('.menu-animation', function () {
return {
beforeAddClass: function (element, className, done) {
if (className == 'highlight') {
TweenLite.to(element, 0.2, {
width: '223',
borderLeft: '10px solid #89CD25',
onComplete: done
});
TweenLite.to(element.find('a'), 0.2, {
color: "#89CD25"
});
}
else {
done();
}
}, beforeRemoveClass: function (element, className, done) {
if (className == 'highlight') {
TweenLite.to(element, 0.4, {
width: '180',
borderLeft: '5px solid #333',
onComplete: done
});
TweenLite.to(element.find('a'), 0.4, {
color: "#5bc0de"
});
}
else {
done();
}
}
};
});

HTML:

<a ng-click="setCurrentCategory(null)"><img class="logo" src="assets/img/eggly-logo.png"></a>
<ul class="nav nav-sidebar">
<li menu-item ng-repeat="category in categories"
class="menu-animation"
ng-class="{'highlight':mouse_over}"
ng-mouseenter="mouse_over = true"
ng-mouseleave="mouse_over = false"
ng-class="{'active':isCurrentCategory(category)}">
<a ng-click="setCurrentCategory(category)">
{{category.name}}
</a>
</li>
</ul>

[AnuglarJS] TweenMax with ngAnimate的更多相关文章

  1. [AngularJS] ngAnimate angular way !!

    Idea is set up javascript  as an api, then just change html to control the behavor. var app = angula ...

  2. 一款基于TweenMax跟随鼠标单击移动的div

    今天给大家分享一款基于TweenMax跟随鼠标单击移动的div.在这款实例中你可以单击任意位置,div会移动到你单击的位置.效果图如下: 在线预览   源码下载 实现的代码. html代码: < ...

  3. TweenMax学习整理--特有属性

    TweenMax学习整理--特有属性   构造函数:TweenMax(target:Object, duration:Number, vars:Object) target:Object -- 需要缓 ...

  4. TweenMax参数说明

    TweenMax 建立在 TweenLite 和 TweenFilterLite 基础之上,因此,又揉合了这二者的功能,使得功能更加的齐备,但是如果说易用性,觉得还是 TweenLite 来得方便一些 ...

  5. tweenmax.js 文档

    TweenMax 参考http://bbs.9ria.com/thread-214959-1-1.html TweenMax 可能是很多人都用的,包括我 但 是最近发现大量的运用就总会产生这样或那样的 ...

  6. angularjs之插件ngRoute和ngAnimate

    使用ngRoute和ngAnimate配合使用,可以实现页面切换的效果. 如果有使用过swiper,就知道这个效果是怎么样的. 代码: <!DOCTYPE html> <html l ...

  7. TweenMax参数补充

    构造函数:TweenMax(target:Object, duration:Number, vars:Object) target:Object -- 需要缓动的对象 duration:Number ...

  8. AngularJS学习--- 动画操作 (Applying Animations) ngAnimate step 12

    1.切换目录 git checkout step-12 npm start 2.效果图 这里在点击右边的缩略图时,会有一个很明显的从下向上的动画过程. 3.代码实现: step11和step12之间的 ...

  9. [CSS3 Animation] TweenMax.staggerTo()

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

随机推荐

  1. Page 16 Exercises 1.2.3 -------Introduction to Software Testing (Paul Ammann and Jeff Offutt)

    Below are four faulty programs. Each includes a test case that results in failure. Answer the follow ...

  2. 【C#】Abstract和Virtual的区别

    一.Virtual方法(虚方法) virtual 关键字用于在基类中修饰方法.virtual的使用会有两种情况: 情况1:在基类中定义了virtual方法,但在派生类中没有重写该虚方法.那么在对派生类 ...

  3. 通过xshell 设置代理上网

    前言: 前段时间,选修了一门并行计算,老师给我们每个人分配了一个linux登录账号,通过这个账号,可能登录学校的一台linux . 一次偶然的机会,了解到可以通过xshell , ssh服务器给本地开 ...

  4. 使用JavaMail API发送邮件

    发送邮件是很常用的功能,注册验证,找回密码,到货通知,欠费提醒等,都可以通过邮件来提醒. Java中发送邮件需要使用javax.mail.jar包,读者可以上网搜索或去官方下载,下载地址为: 下面贴上 ...

  5. Make the “Check out” function available in the office document opened with Document ID link

    I found a solution to make the “Check out” function available in the office document opened with Doc ...

  6. 题目连接:http://acm.zznu.edu.cn/problem.php?id=1329

    题目大意: 定理:把一个至少两位的正整数的个位数字去掉,再从余下的数中减去个位数的5倍.当且仅当差是17的倍数时,原数也是17的倍数 . 例如,34是17的倍数,因为3-20=-17是17的倍数:20 ...

  7. HDU 5821 Ball (排序)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5821 有n个盒子,每个盒子最多装一个球. 现在进行m次操作,每次操作可以将l到r之间盒子的球任意交换. ...

  8. 关于html和body高度 登录页面登录框永远保持在页面垂直水平居中位置

    HTML CSS 解说,水平居中就不用多说了,给div.login_wrap设置个宽度,然后margin:0 auto;就可以做到.但是这里这样做,这里使用了两层div 外层使用margin:0 au ...

  9. Flex data

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  10. Jquery 提示

    1  文字提示: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...