-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
84 lines (67 loc) · 2.91 KB
/
index.js
File metadata and controls
84 lines (67 loc) · 2.91 KB
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
function openImage(imgSrc) {
document.getElementById("imageModal").style.display = "block";
document.getElementById("modalImg").src = imgSrc;
}
function closeImage() {
document.getElementById("imageModal").style.display = "none";
}
// for Word Animation
let i = 0;
const randomizeText = () => {
const phrase = document.querySelector('.random-word');
const compStyles = window.getComputedStyle(phrase);
const animation = compStyles.getPropertyValue('animation');
const animationTime = parseFloat(animation.match(/\d*[.]?\d+/)) * 1000;
const phrases = ['Front-End Developer', 'WordPress Front-End Developer', 'Web Designer','Full Stack Web Developer','Front-End Developer', 'WordPress Front-End Developer', 'Web Designer','Full Stack Web Developer','Front-End Developer', 'WordPress Front-End Developer', 'Web Designer','Full Stack Web Developer',
'Front-End Developer', 'WordPress Front-End Developer', 'Web Designer','Full Stack Web Developer','Front-End Developer', 'WordPress Front-End Developer', 'Web Designer','Full Stack Web Developer'];
i = randomNum(i, phrases.length);
const newPhrase = phrases[i];
setTimeout(() => {
phrase.textContent = newPhrase;
}, 400); // time to allow opacity to hit 0 before changing word
}
const randomNum = (num, max) => {
let j = Math.floor(Math.random() * max);
// ensure diff num every time
if (num === j) {
return randomNum(i, max);
} else {
return j;
}
}
const getAnimationTime = () => {
const phrase = document.querySelector('.random-word');
const compStyles = window.getComputedStyle(phrase);
let animation = compStyles.getPropertyValue('animation');
// firefox support for non-shorthand property
animation != "" ? animation : animation = compStyles.getPropertyValue('-moz-animation-duration');
// webkit support for non-shorthand property
animation != "" ? animation : animation = compStyles.getPropertyValue('-webkit-animation-duration');
const animationTime = parseFloat(animation.match(/\d*[.]?\d+/)) * 1000;
return animationTime;
}
randomizeText();
setInterval(randomizeText, getAnimationTime());
// --------End for Word Animation --------
// for backgorund
particlesJS("particles-js", {
particles: {
number: { value: 80, density: { enable: true, value_area: 800 } },
color: { value: "#72f6f2" },
shape: { type: "circle" },
opacity: { value: 0.5, random: true },
size: { value: 3, random: true },
move: { enable: true, speed: 1.5, direction: "none", out_mode: "out" }
},
interactivity: {
events: {
onhover: { enable: true, mode: "repulse" },
onclick: { enable: true, mode: "push" }
},
modes: {
repulse: { distance: 100, duration: 0.4 },
push: { particles_nb: 4 }
}
},
retina_detect: true
});