-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.js
84 lines (73 loc) · 2.06 KB
/
header.js
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
var logo = $(".Logo");
var logoEmitter = $("#LogoEmitter");
var logoTimeline = new TimelineMax();
var particles = ["normal", "dark", "bright"];
function getRandom(low, high) {
return Math.floor(Math.random() * (1 + high - low)) + low;
}
function zigZag(item, duration, timeline) {
timeline.play(0);
}
for (var i = 0; i < 40; i++) {
var x = getRandom(-60, 65),
y = getRandom(65, 65),
startX = i % 2 == 0 ? i * 2.5 : -1 * (i * 2.5),
negative = getRandom(0, 1) == 1 ? -1 : 1,
degree = getRandom(90, 180),
particle = $('<div class="particle"></div>'),
fill = $('<div class="fill"></div>'),
duration = getRandom(8, 15), // travel time
theDelay = getRandom(0, 8),
particleMovement = new TimelineMax();
fill.addClass(particles[getRandom(0, particles.length - 1)]);
particle.append(fill);
logoEmitter.append(particle); //add it to emitter
// Create the small movements in each particle
// indepenedent of the path
particleMovement.to(
fill,
duration / 2,
{
x: "+=" + getRandom(-5, 5),
y: "+=" + getRandom(-5, 5),
ease: Back.easeOut.config(1.4)
},
getRandom(0, 2)
);
particleMovement.to(
fill,
duration / 2,
{
x: "+=" + getRandom(-5, 5),
y: "+=" + getRandom(-2, 2),
ease: Back.easeOut.config(1.4)
},
getRandom(0, 2)
);
// Set initatial position of the particle based on if its neg or not
if (y * negative > 0) {
TweenMax.set(particle, { y: "+=37px", x: '+='+startX });
} else {
TweenMax.set(particle, { y: "-=25px", x: '+='+startX });
}
logoTimeline.to(
particle,
duration,
{
x: '+='+x,
y: '+='+ (negative * y),
opacity: 0,
ease: Power1.easeOut,
repeat: -1,
scale: getRandom(0.98,1),
repeatDelay: theDelay,
transformOrgin: "50% 50%",
onRepeat: zigZag,
onRepeatParams: [fill, duration, particleMovement],
onStartParams: [fill, duration, particleMovement],
onStart: zigZag
},
theDelay
);
}
var blueParticles = ['blue', 'darkBlue', 'lightBlue']