-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation-7.js
39 lines (34 loc) · 999 Bytes
/
animation-7.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
var BOX_FALL_DURATION = 2000;
var BOX_NEXT_OFFSET = 250;
var DELAY = 3000;
var SPARK_ANIM_DURATION = 500;
var timeline = anime.timeline({
direction: "alternate",
loop: true
});
var boxes = document.querySelectorAll('g[id^=Box-]');
var targets = [];
for(var i = 0; i < boxes.length;i++){
targets.unshift(boxes[i]);
};
timeline.add({
targets: targets,
translateY: [-230, 0],
easing: 'easeInQuad',
delay: function(x, i){
return i * BOX_NEXT_OFFSET;
},
duration: BOX_FALL_DURATION
});
animateLines(timeline, '#Sparks>line', DELAY , SPARK_ANIM_DURATION);
function animateLines(timeline, targets, totalDelay, duration) {
const count = Math.round( totalDelay / (2 * duration) );
for(var i = 0; i < count;i++){
timeline.add({
targets: targets,
strokeDashoffset: (i % 2)? [0, anime.setDashoffset] : [anime.setDashoffset, 0],
easing: 'linear',
duration: duration
});
}
}