-
Notifications
You must be signed in to change notification settings - Fork 2
/
03-staggers.html
38 lines (30 loc) · 1.04 KB
/
03-staggers.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>staggers</title>
<link rel="stylesheet" href="./css/main.css">
</head>
<body>
<button id="btn">click</button>
<div class="cube box-100 bg-red"></div>
<div class="cube box-100 bg-blue"></div>
<div class="cube box-100 bg-yellowgreen"></div>
<script src="./GSAP3/gsap.min.js"></script>
<script>
/*
捨棄舊的staggerTo、staggerFrom、staggerFromTo方法
現在可以再一般的補間動化中添加交錯等動畫功能
*/
const btn = document.getElementById('btn');
btn.addEventListener('click', ()=>{
//OLD
// TweenMax.staggerTo(".cube", 0.5, {x:"+=100"}, 0.5);
//NEW
gsap.to(".cube", {duration: 1, x:"+=100", stagger: 0.5});
});
</script>
</body>
</html>