-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionality.js
43 lines (40 loc) · 1.45 KB
/
functionality.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
var color = "teal";
var rand = getRandomInt(5, 20);
$(document).ready(function() {
$(document).mousemove(function(event) {
var x = event.pageX;
var y = event.pageY;
elem = document.elementFromPoint(x - window.pageXOffset, y - window.pageYOffset);
console.log(elem.tagName);
if (elem.tagName == "HTML") {
appendElem(x, y, rand, color, "body");
}
if (color == "rgba(211, 206, 235)") {
color = "rgba(203, 245, 231)";
} else {
color = "rgba(211, 206, 235)";
}
rand = getRandomInt(5, 20);
});
$(".top-link").click(function(event) {
const elem = event.target;
$(".top-link-active").removeClass("top-link-active");
$(elem).addClass("top-link-active");
box_elem = "#" + elem.innerText
const box_sections = ["#about", "#experience", "#teaching"];
box_sections.forEach((section) => $(section).hide());
$(box_elem).show();
});
});
function appendElem(x, y, rand, color, elem) {
var left = 100*(x/window.innerWidth) + "vw";
var top = 100*(y/window.innerHeight) + "vh";
$(elem).append('<div class = "teenybubs" style = "position:absolute; opacity:0.2; background-color:' + color + '; top:' + top + '; margin-left:' + left + '; width:' + rand + 'px; height: ' +
rand + 'px; border-radius:' + rand + 'px"></div>');
}
// @SOURCE mozilla libraries!!
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}