TimelineLite is a piece of the Greensock TweenMax library that provides the ability to create sequenced animation with very little code or setup.

Key value:

fromTo( target:Object, duration:Number, fromVars:Object, toVars:Object, position:* ) 

Read More: https://egghead.io/lessons/angularjs-greensock-timelinelite-animation-sequences

Example:

angular.module('website', ['ngAnimate'])
.controller('MainCtrl', function ($scope) {
$scope.slides = [
{bg: 'images/bg3.jpg', avatar: 'images/john.png', title: 'Big Boss', subtitle: 'Monkey king'},
{bg: 'images/bg1.jpg', avatar: 'images/joel.png', title: 'Second Boss', subtitle: 'Monkey leader'},
{bg: 'images/bg2.jpg', avatar: 'images/lukas.png', title: 'Other monkeys', subtitle: 'MOPSI'}
]; $scope.direction = 'left';
$scope.currentIndex = 0; $scope.setCurrentSlideIndex = function (index) {
$scope.direction = (index > $scope.currentIndex) ? 'left' : 'right';
$scope.currentIndex = index;
}; $scope.isCurrentSlideIndex = function (index) {
return $scope.currentIndex === index;
};
})
.animation('.slide-animation', function () {
return {
//remove the current card
beforeAddClass: function (element, className, done) { if (className == 'ng-hide') {
var scope = element.scope(),
finishPoint = element.parent().width();
console.log(element.parent().width()); if(scope.direction !== 'right') finishPoint = -finishPoint; TweenLite.to(element, 0.5, {left:finishPoint, ease: Ease.easeInOut, onComplete: done});
}
else {
done();
}
},
//fade in selected card
removeClass: function (element, className, done) {
if (className == 'ng-hide') {
var scope = element.scope(),
startPoint = element.parent().width(),
//start a timeline
tl = new TimelineLite(); if(scope.direction === 'right') startPoint = -startPoint; //chain methods, animate one by one
//.fromTo( target:Object, duration:Number, fromVars:Object, toVars:Object, position:* )
//fromTo(element.find('.title'), 0.5, { left: -200, alpha: 0}, {left:0, alpha:1, ease:Ease.easeInOut} )
//element.find('.title'): find the element
//0.5: 500ms
//{left: -200, alpha: 0}: animate start with left: -200 and alpha : 0
//{left: 0, alpha: 1, ease: Ease.easeInOut}: animate end with left: 0....
tl.fromTo(element, 0.1, { left: startPoint}, {left:0, ease: Ease.easeInOut, onComplete: done})
.fromTo(element.find('.title'), 0.5, { left: -200, alpha: 0}, {left:0, alpha:1, ease:Ease.easeInOut} )
.fromTo(element.find('.subtitle'), 0.5, { left: -200, alpha: 0}, {left:0, alpha:1, ease:Ease.easeInOut} )
.fromTo(element.find('.avatar'), 0.5, { left: 800, alpha: 0}, {left:380, alpha:1, ease:Ease.easeInOut} );
}
else {
done();
}
}
};
});
<!DOCTYPE html>
<html ng-app="website">
<head>
<meta charset="utf-8">
<title>Egghead.io - Greensock TimelineLite</title> <link href="assets/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/timeline.greensock.css">
</head> <body ng-controller="MainCtrl"> <div class="slider">
<div ng-repeat="slide in slides"
ng-hide="!isCurrentSlideIndex($index)"
class="slide slide-animation">
<img class="nonDraggableImage" ng-src="{{slide.bg}}">
<img class="nonDraggableImage avatar" ng-src="{{slide.avatar}}">
<h1 class="title"><span>{{slide.title}}</span></h1>
<h3 class="subtitle"><span>{{slide.subtitle}}</span></h3>
</div>
</div> <div class="nav">
<div ng-repeat="slide in slides"
ng-class="{'active':isCurrentSlideIndex($index)}"
ng-click="setCurrentSlideIndex($index)">
<h3>{{slide.title}}</h3>
</div>
</div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.10.3/TweenMax.min.js"></script> <script src="js/timeline.greensock.js"></script> </body>
</html>

[AngularJS+ GSAP] Greensock TimelineLite Animation Sequences的更多相关文章

  1. GreenSock & SVG Animation

    GreenSock & SVG Animation refs https://greensock.com/ https://greensock.com/learning/ GSAP https ...

  2. JS动画 | 用TweenMax实现收集水滴效果

    之前在CodePen上接触了TweenMax, 被它能做到的酷炫效果震撼了. (文末放了5个GSAP的效果GIF) 最近要做一个"收集水滴"的动效, 于是就试用了一下TweenMa ...

  3. Web Best Practices

    Web Best Practices General Google WebFundamentals - Github JavaScript Style Guide - Github Google In ...

  4. Dojo特效(翻译)

    http://dojotoolkit.org/documentation/tutorials/1.10/effects/index.html In this tutorial, we will exp ...

  5. Calculating Stereo Pairs

    Calculating Stereo Pairs Written by Paul BourkeJuly 1999 Introduction The following discusses comput ...

  6. 大话ASP.NET(第二篇,Angular结构篇--翻译)

    AngularJS API Docs Welcome to the AngularJS API docs page. These pages contain the AngularJS referen ...

  7. AngularJS1.X学习笔记14-动画(解读文档)

    最近在看算法分析,那个大O啊,小o啊,分治法啊(目前就看到这里),真是搞死了.这回呢休息一下,学学AngularJS动画,上一篇文章根据自由男人的书简单谈到了动画的话题,发现反响很大(好吧,我说慌了, ...

  8. PhoenixFD插件流体模拟——UI布局【Export】详解

    Liquid Export 流体导出 本文主要讲解Export折叠栏中的内容.原文地址:https://docs.chaosgroup.com/display/PHX3MAX/Liquid+Expor ...

  9. web 常用开发工具

    he把字符转化为实体字符 awesome-vue Vue资源 clipboard.js 粘贴板 Share.js 一键分享 nock 模拟异步数据 Clamp.js 限制文本最大行数 pinyin 将 ...

随机推荐

  1. 修改ssh服务的默认端口

    修改ssh服务的默认端口 1.查看当前服务端口 一般ssh服务的默认端口为22端口,查看监听的端口用netstat,如下: [root@ansiblemoniter ~]# netstat -tnlp ...

  2. activity切换时的overridePendingTransition动画效

      注意,切换方法overridePendingTransition只能在startActivity和finish方法之后调用.第一个参数为第一个Activity离开时的动画,第二参数为所进入的Act ...

  3. 关系数据库&amp;&amp;NoSQL数据库

    在过去,我们只需要学习和使用一种数据库技术,就能做几乎所有的数据库应用开发.因为成熟稳定的关系数据库产品并不是很多,而供你选择的免费版本就更加少了,所以互联网领域基本上都选择了免费的MySQL数据库. ...

  4. memset()实现及细节

    memset是计算机中C/C++语言函数.将s所指向的某一块内存中的前n个 字节的内容全部设置为ch指定的ASCII值, 块的大小由第三个参数指定,这个函数通常为新申请的内存做初始化工作, 其返回值为 ...

  5. WCF配置文件全攻略

    參考:http://www.cnblogs.com/wayfarer/archive/2007/08/24/867987.html http://www.cnblogs.com/scy251147/a ...

  6. 25个完美的Opencart模板,让顾客无法抗拒!

    在线开展业务是当前的流行趋势.OpenCart(点击这里下载),作为一个流行的开源PHP电子商务系统,获取OpenCart模板不在像以前那么困难了.OpenCart容易安装,模板支持良好,扩展功能包十 ...

  7. Python 最佳实践

    前言 对我来说,以前每次面试是我审视自己,检验自己的一种方式.每次准备面试,以及被面试官问住的时候才会发现,其实我python我学的还不够好.工作中也是,可以从其他的同事那里获得成长.但是我今天说的是 ...

  8. mysql 的 GROUP_CONCAT

    GROUP_CONCAT 通常跟 group by 一起用,但也可以不用.例:select GROUP_CONCAT(pct_id) as pct_ids from (select max(pct_i ...

  9. Hadoop中的辅助类ToolRunner和Configured的用法详解

    在开始学习hadoop时,最痛苦的一件事就是难以理解所写程序的执行过程,让我们先来看这个实例,这个测试类ToolRunnerTest继承Configured的基础上实现了Tool接口,下面对其用到的基 ...

  10. cocos2d-js屏幕任何位置点击开始的实现

    ctor:function () { this._super(); if ('mouse' in cc.sys.capabilities) cc.eventManager.addListener({ ...