-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMMM-Valentine.js
50 lines (39 loc) · 1.39 KB
/
MMM-Valentine.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
/* Magic Mirror
* Module: MMM-Valentine
*
* By Sergey Morozov
* Based on https://github.com/MichMich/MMM-Snow
* MIT Licensed.
*/
Module.register("MMM-Valentine",{
defaults: {
valentinesCount: 50,
valentinesSize: 1.00
},
getStyles: function() {
return [ "MMM-Valentine.css" ]
},
getDom: function() {
var wrapper = document.createElement("div")
wrapper.className = "valentine-wrapper";
var heart, jiggle, size, rotation;
for(var i = 0; i < this.config.valentinesCount; i++) {
heart = document.createElement("div")
heart.className = "valentine-heart"
jiggle = document.createElement("div");
jiggle.style.animationDelay = (Math.random() * 4) + "s";
jiggle.style.animationDuration = ((Math.random() * 30) + 30) + "s";
jiggle.className = "heart" + (Math.round(Math.random() * 14) + 1);
size = (Math.random() * 0.75) + 0.25 + this.config.valentinesSize;
rotation = (Math.floor(Math.random() * 81) - 40);
jiggle.style.transform = "scale(" + size + ", " + size + ") rotate(" + rotation + "deg)";
jiggle.style.opacity = size - this.config.valentinesSize;
heart.appendChild(jiggle);
heart.style.left = ((Math.random() * 100) - 10) + "%";
heart.style.animationDelay = (Math.random() * 100) + "s";
heart.style.animationDuration = 100 - (Math.random() * 50 * (size - this.config.valentinesSize)) + "s";
wrapper.appendChild(heart);
}
return wrapper;
}
});