[AnuglarJS] TweenMax with ngAnimate
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的更多相关文章
- [AngularJS] ngAnimate angular way !!
Idea is set up javascript as an api, then just change html to control the behavor. var app = angula ...
- 一款基于TweenMax跟随鼠标单击移动的div
今天给大家分享一款基于TweenMax跟随鼠标单击移动的div.在这款实例中你可以单击任意位置,div会移动到你单击的位置.效果图如下: 在线预览 源码下载 实现的代码. html代码: < ...
- TweenMax学习整理--特有属性
TweenMax学习整理--特有属性 构造函数:TweenMax(target:Object, duration:Number, vars:Object) target:Object -- 需要缓 ...
- TweenMax参数说明
TweenMax 建立在 TweenLite 和 TweenFilterLite 基础之上,因此,又揉合了这二者的功能,使得功能更加的齐备,但是如果说易用性,觉得还是 TweenLite 来得方便一些 ...
- tweenmax.js 文档
TweenMax 参考http://bbs.9ria.com/thread-214959-1-1.html TweenMax 可能是很多人都用的,包括我 但 是最近发现大量的运用就总会产生这样或那样的 ...
- angularjs之插件ngRoute和ngAnimate
使用ngRoute和ngAnimate配合使用,可以实现页面切换的效果. 如果有使用过swiper,就知道这个效果是怎么样的. 代码: <!DOCTYPE html> <html l ...
- TweenMax参数补充
构造函数:TweenMax(target:Object, duration:Number, vars:Object) target:Object -- 需要缓动的对象 duration:Number ...
- AngularJS学习--- 动画操作 (Applying Animations) ngAnimate step 12
1.切换目录 git checkout step-12 npm start 2.效果图 这里在点击右边的缩略图时,会有一个很明显的从下向上的动画过程. 3.代码实现: step11和step12之间的 ...
- [CSS3 Animation] TweenMax.staggerTo()
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
随机推荐
- WebGoat学习——SQL注入(SQL Injection)
SQL注入(SQL Injection) 所谓SQL注入式攻击,就是攻击者把SQL命令插入到Web表单的输入域或页面请求的查询字符串,欺骗服务器执行恶意的SQL命令.攻击者通过web请求提交带有影响正 ...
- SAS、R以及SPSS的比较__统计语言大战
- (转载)OC学习篇之---类的延展
前一篇文章我们介绍了类的类目概念和使用,那么这篇文章我们继续来介绍一下OC中的一个特性:延展. 其实说白了,延展就是弥补C语言中的前向申明,我们知道,在C语言中,如果你想调用一个函数的话,那么在此之前 ...
- 如何杀掉当前正在执行的hadoop任务
[root@Slave01 ~]# hadoop job -listDEPRECATED: Use of this script to execute mapred command is deprec ...
- Hadoop入门简介
一.Hadoop简介 1.1.Hadoop主要进行分布式存储和分布式计算 1.1-1.HDFS:分布式文件系统 1.1-2.MapReduce:并行计算框架 1.2.Hadoop用来做什么? 搭建大型 ...
- 第二百二十三天 how can I 坚持
今天双十一,过得有点郁闷,昨天鱼死了不说,抢的羽绒服今天才发现是棉服,结果又买了个海澜之家的,搞的今天凌晨买的东西全都写退了,除了小米耳机. 光棍节,好纠结.爱要怎么说出口,你才不会拒绝啊,愁人啊. ...
- Django Signals 从实践到源码分析(转)
原文:http://foofish.net/blog/66/django-signals 当某个事件发生的时候,signal(信号)允许senders(发送者)用来通知receivers(接收者),通 ...
- *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
kei编译时提示: *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL *** WARNING L1:reference made to unresolved ext ...
- unigui TUniTreeView demo
unit untTree; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...
- 代码中设置excel自定义格式为[红色]的处理方法
有时候,excel的自定义格式设置时 ,会遇到需要设置为¥#,##0;[红色]¥-#,##0的格式. 其中会带一个颜色标记,但是如果这样的一句代码,放在英文版的Office里面,就失效了,因为英文版应 ...