[AngularJS+ GSAP] Greensock TimelineLite Animation Sequences
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的更多相关文章
- GreenSock & SVG Animation
GreenSock & SVG Animation refs https://greensock.com/ https://greensock.com/learning/ GSAP https ...
- JS动画 | 用TweenMax实现收集水滴效果
之前在CodePen上接触了TweenMax, 被它能做到的酷炫效果震撼了. (文末放了5个GSAP的效果GIF) 最近要做一个"收集水滴"的动效, 于是就试用了一下TweenMa ...
- Web Best Practices
Web Best Practices General Google WebFundamentals - Github JavaScript Style Guide - Github Google In ...
- Dojo特效(翻译)
http://dojotoolkit.org/documentation/tutorials/1.10/effects/index.html In this tutorial, we will exp ...
- Calculating Stereo Pairs
Calculating Stereo Pairs Written by Paul BourkeJuly 1999 Introduction The following discusses comput ...
- 大话ASP.NET(第二篇,Angular结构篇--翻译)
AngularJS API Docs Welcome to the AngularJS API docs page. These pages contain the AngularJS referen ...
- AngularJS1.X学习笔记14-动画(解读文档)
最近在看算法分析,那个大O啊,小o啊,分治法啊(目前就看到这里),真是搞死了.这回呢休息一下,学学AngularJS动画,上一篇文章根据自由男人的书简单谈到了动画的话题,发现反响很大(好吧,我说慌了, ...
- PhoenixFD插件流体模拟——UI布局【Export】详解
Liquid Export 流体导出 本文主要讲解Export折叠栏中的内容.原文地址:https://docs.chaosgroup.com/display/PHX3MAX/Liquid+Expor ...
- web 常用开发工具
he把字符转化为实体字符 awesome-vue Vue资源 clipboard.js 粘贴板 Share.js 一键分享 nock 模拟异步数据 Clamp.js 限制文本最大行数 pinyin 将 ...
随机推荐
- bzoj1833 digit
这道题其实挺水,只是写的时候需要想清楚.我的方法是: 1.将[a,b]转化为[0,b+1)-[0,a) 2.预处理出非0的v在区间[0,10^p)出现次数以及0在区间[0,10^p)出现数 3.将一个 ...
- Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.
用TexStudio编辑文档时,不知是多加了空格还是啥,总是提示如下错误: Package inputenc Error: Unicode char \u8: not set up for use w ...
- Intent相关
Intent是什么? 翻译为:意图,目的(名词) 其实根本没必要管它是什么,看看它能做什么就好了. 不过后来我知道了,它就是个机制----通信机制-----android的许多组件间的交流要依赖它. ...
- SlidingPaneLayout的基本使用
SlidingPaneLayout是V4包中新添加的组件,可以实现两列面板的切换.说先来看看API文档的说明: ? 1 SlidingPaneLayout provides a horizonta ...
- Coffee Script 笔记 1
安装node 虽然官网提供了单文件bin的版本 但是并不知道怎么安装npm 于是乎还是得安装msi (坑 当使用 coffee -w -c . 监视文件改变 即时编译的时候会 提示 Error: T ...
- C#读取文件为byte数组
private byte[] FileContent(string fileName) { using (FileStream fs = new FileStream(fileName, FileMo ...
- labview图形和图表的类型
http://zone.ni.com/reference/zhs-XX/help/371361L-0118/lvconcepts/types_of_graphs_and_charts/ LabVIEW ...
- LeetCode283:Move Zeros
Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...
- Linux应用总结:自动删除n天前日志
linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,让系统定时清理一些不需要的文件很有一种爽快的事情.不用你去每天惦记着是否需要清理日志 ...
- Python基础 数字、字符串、列表、元组、字典
Number(数字)---> int.float.complex(复数) class int 在Python3中,整形(int)就是常见的整数:1,100,500,1000...... 浮点型( ...