[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 将 ...
随机推荐
- C# 保留2位小数
1.只要求保留N位不四舍5入 float f = 0.55555f; int i =(int)(f * 100); ...
- 基本的SQL Server 语句,包含 增、删、改、查 程序员必会
这是我以前学习时, 整理的一套基础SQL Server增.删.改.查 等语句 ,初学者可以从上往下学完. 也方便自己忘记时翻看! create database SQLschool go --批 go ...
- 【工作备忘】suricata
因为工作遇到的困难,我向suricata的某个作者发送了邮件. On Wed, Sep 11, 2013 at 8:22 AM, likeyi <929812468@qq.com> wro ...
- PHP强大的内置filter (二) 完
<?php #Sanitize filters #Sanitize filters 可以清理掉不规范的字符 # FILTER_SANITIZE_EMAIL 可以清理除了 字母和数字 以及 !#$ ...
- 使用arm开发板搭建无线mesh网络(二)
上篇博文介绍了无线mesh网络和adhoc网络的区别,这篇文章将介绍无线mesh网络的骨干网节点的组建过程.首先需要介绍下骨干网节点的设计方案:每个骨干网节点都是由一块友善之臂的tiny6410 ar ...
- POJ2406----Power Strings解题报告
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 43514 Accepted: 18153 D ...
- Linux下的sed流编辑器命令详解
sed是stream editor的简称,也就是流编辑器.它一次处理一行内容,处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内 ...
- 什么是IntelAMT
IntelAMT 全称为INTEL主动管理技术,该技术允许IT经理们远程管理和修复联网的计算机系统,而且实施过程是对于服务对象完全透明的,从而节省了用户的时间和计 算机维护成本.释放出来的iAMT构架 ...
- emWin5.24 VS2008模拟LCD12864 stm32 RTX移植 【worldsing笔记】
emWin for 12864 并口移植 源代码下载:RTX_emWin5.24_Keil_VS2008-20141122.zip 硬件环境: CPU: stm32f103ve LCD:st7 ...
- php redis 分布式类
配置: $redis_config = array( 'prefix' => 'ylmall_', 'master' => array( 'host' => "192.16 ...