制作H5动画页面

I belong to : Collection


突然看到有H5页面外快做,看到微信朋友圈发的那些H5页面里面都用的了TweenMax,所以来研究一下,结果吓一跳,太太太强大了!!!!

复习一下CSS3

background-size: width height
background-clip:content-box/padding-box/border-box
background-origin:content-box/padding-box/border-box
background-image:url(bg_flower.gif),url(bg_flower_2.gif);多个背景

text-shadow:水平阴影 垂直阴影 模糊距离 阴影的颜色
box-shadow: 水平阴影 垂直阴影 模糊距离  阴影的尺寸 阴影的颜色

clip: rect (top, right, bottom, left)
<top>和<bottom>指定偏移量是从元素盒子顶部边缘算起;
<left>和<right>指定的偏移量是从元素盒子左边边缘算起。


word-wrap:break-word
@font-face

转换
transform:translate()/rotate()/scale()/skew()/matrix()/rotateX()/rotateY()

动画
transition:transition-property transition-duration transition-timing-function transition-delay
        @keyframes myfirst
        {
        from {background: red;}
        to {background: yellow;}
        }
        animation: myfirst 5s;

多列,这个只能平均分
column-count
column-gap
column-rule

resize:both 可以鼠标拖拽
box-sizing:border-box;

outline:2px solid red;
outline-offset:15px;

GreenSock

参考资料

了解资料

greensock get-started-js

3D Transforms & More CSS3 Goodies Arrive in GSAP JS

基础实例

Jump Start: GSAP JS

Timeline Tip: Understanding the Position Parameter

Basic play / pause toggle button

create a playful Jump Loader animation

进阶 Writing Smarter Animation Code

https://greensock.com/examples-showcases

https://tympanus.net/codrops/ 隆重介绍这个网站,上面有好多好多好看的动画

介绍

GreenSock Animation Platform(GSAP) 是一套脚本动画工具。它包括:

{% blockquote %}

{% endblockquote %}

TweenLite 可以解决基础动画

动画曲线

Lightweight TweenLite: Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, and Strong

EasePack : Elastic, SlowMo, Bounce, SteppedEase, Sine, Circ, and Expohttps://greensock.com/ease-visualizer

2D转换

rotation, 
scaleX,
scaleY,
scale, 
skewX, 
skewY,
x, (相当于css的translateX)
y, (相当于css的translateY)
xPercent, 
yPercent

3D转换

rotationX, 
rotationY, 
rotationZ (identical to regular "rotation"), 
z,(相当于css的translateZ)
perspective,
transformPerspective

重要属性

TimelineLite 让动画有序和组织

//create a TimelineLite instance
var tl = new TimelineLite();

//append a to() tween
tl.to(element, 1, {width:"50%"});

//add another sequenced tween (by default, tweens are added to the end of the timeline which makes sequencing simple)
tl.to(element, 1, {height:"300px", ease:Elastic.easeOut});

//offset the next tween by 0.75 seconds so there's a gap between the end of the previous tween and this new one
tl.to(element, 1, {opacity:0.5}, "+=0.75");

//overlap the next tween with the previous one by 0.5 seconds (notice the negative offset at the end)
tl.to(element, 1, {backgroundColor:"#FF0000"}, "-=0.5");

//animate 3 elements (e1, e2, and e3) to a rotation of 60 degrees, and stagger their start times by 0.2 seconds
tl.staggerTo([e1, e2, e3], 1, {rotation:60}, 0.2);

//then call myFunction()
tl.call(myFunction);

//now we can control the entire sequence with the standard methods like these:
tl.pause();
tl.resume();
tl.restart();
tl.reverse();
tl.play();

//jump to exactly 2.5 seconds into the animation
tl.seek(2.5);

//slow down playback to 10% of the normal speed
tl.timeScale(0.1);

//add a label named "myLabel" at exactly 3 seconds:
tl.add("myLabel", 3);

//add a tween that starts at "myLabel"
tl.add( TweenLite.to(element, 1, {scale:0.5}), "myLabel");

//jump to "myLabel" and play from there:
tl.play("myLabel");

TimelineMaxTweenMax 多一些功能

repeat, 
yoyo:Boolean
repeatDelay and more.

TimelineMax 还有方法

tweenTo(), 
currentLabel(),
getLabelBefore() 
getLabelAfter() and more.

Overwriting other tweens

all,none,auto

TweenLite.defaultOverwrite = "all";

其它

stagger可以让多个元素执行同一个动画