본문으로 바로가기

트윈맥스 TweenMax

category 퍼블리싱/TIP 2017. 9. 27. 15:11

카테고리를 어디로 넣어야할지 몰라서 일단 여기에.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// 이하 포함
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TweenLite.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TimelineLite.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/plugins/CSSPlugin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/easing/EasePack.min.js"></script>
 
// Simple Tween
TweenLite.to(allItems, 1.5, {y: 20, autoAlpha: 0});
 
// Simple Tween
TweenLite.from(img, 1, {x: -100});
TweenLite.from(h2, .5, {autoAlpha: 0, delay: 1}); // delay로 이후 동작 설정가능.
 
// Simple Tween
TweenLite.from(img, 1, {
    x: -200
    ease: RoughEase.ease.config({ 
        template: Power0.easeNone, 
        strength: 1
        points: 20
        taper: "none"
        randomize: true
        clamp: true
    })
});
TweenLite.from(img, 1, {
    x: -100
    ease: SlowMo.ease.config(0.70.7false)
});
TweenLite.from(img, 1, {
    x: -300
    ease: SteppedEase.config(20)
}); // ease를 이용해서 다양한 움직임 연출가능.
 
 
// Simple Callback Functions
TweenLite.from(img, 1, {
    x: -200
    ease:Power1.easeInOut, 
    onStart: onStart,
    onUpdate: onUpdate,
    onComplete: onComplete
});
 
function onStart(){
    console.log('animation started');
}
function onUpdate(){
    h2.text(i++);
}
function onComplete(){
    console.log('animation completed');
 
var img = $('img'),
    h2 = $('h2'),
    h1 = $('h1'),
    intro = $('.intro'),
    listItem = $('ul li'),
    tl = new TimelineLite();
 
    // Animating Multiple Objects - 하나씩 컨트롤 할수도 있고
    TweenLite.from(h1, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut, delay: 0.2});
    TweenLite.from(intro, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut, delay: 0.4});
    TweenLite.from(img, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut, delay: 0.6});
    TweenLite.from(h2, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut, delay: 0.8});
    TweenLite.from(listItem, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut, delay: 1});
 
    tl // 타임라인 인스턴스생성해서 관리할수도 있음.
    .from(h1, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut})
    .from(intro, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut}, '-=0.15')
    .from(img, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut}, '-=0.15')
    .from(h2, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut}, '-=0.15')
    .from(listItem, 0.3, {y: -15, autoAlpha: 0, ease:Power1.easeOut}, '-=0.15');
    
 
 
// Controlling Timeline Playback
tl
    .from(h1, 1, {y: -15, autoAlpha: 0, ease:Power1.easeOut})
    .from(intro, 1, {y: -15, autoAlpha: 0, ease:Power1.easeOut})
    .from(img, 1, {y: -15, autoAlpha: 0, ease:Power1.easeOut})
    .from(h2, 1, {y: -15, autoAlpha: 0, ease:Power1.easeOut})
    .from(listItem, 1, {y: -15, autoAlpha: 0, ease:Power1.easeOut});
    .staggerFrom(buttons, 1, {cycle: {
        x: [50-50],
        scale: [20.5]
    }, autoAlpha: 0, ease:Power1.easeOut}, 0.5);  // staggering animations 
 
 
$('#btnPlay').on('click',function(){
    tl.play();
});
 
$('#btnPause').on('click',function(){
    tl.pause();
});
 
$('#btnResume').on('click',function(){
    tl.resume();
});
 
$('#btnReverse').on('click',function(){
    tl.reverse();
});
 
$('#btnSpeedUp').on('click',function(){
    tl.timeScale(8);
});
 
$('#btnSlowDown').on('click',function(){
    tl.timeScale(0.5);
});
 
$('#btnSeek').on('click',function(){
    tl.seek(1);
});
 
$('#btnProgress').on('click',function(){
    tl.progress(0.5);
});
 
$('#btnRestart').on('click',function(){
    tl.restart();
});  // 타임라인에 접근해서 이벤트 걸 수 있음
 
 
 
 
cs


'퍼블리싱 > TIP' 카테고리의 다른 글

[css trick] text-align : justify  (0) 2017.09.22
BEM(Block Element Modifier)에 관하여  (0) 2016.06.22
개인정보보호방침  (0) 2016.05.18
모바일전용사이트 분기시키기  (0) 2016.04.21
모바일웹에서의 FOOTER  (0) 2016.04.06