-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
executable file
·130 lines (99 loc) · 3.43 KB
/
script.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
window.addEventListener("DOMContentLoaded", () => {
const nameElement = document.getElementById("name");
const nameText = "Léa Rostoker.";
let charIndex = 0;
let timer;
function type() {
const text = nameText.slice(0, charIndex);
nameElement.textContent = text;
charIndex++;
if (charIndex <= nameText.length) {
timer = setTimeout(type, 100);
} else {
setTimeout(function() {
profileImage.style.display = "block";
}, 20);
}
}
type();
});
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetElement = document.querySelector(this.getAttribute('href'));
const offset = -70;
window.scrollTo({
top: targetElement.offsetTop + offset,
behavior: 'smooth'
});
});
});
//CONTACT FORM
function sendEmail(){
var params = {
reply_email: getElementById("email").value,
message: getElementById("message").value
};
const serviceID = "service_qq2k9tr";
const templateID = "template_h1kxlya";
emailjs
.send( serviceID, templateID, params )
.then((res) => {
document.getElementById("email").value = "";
document.getElementById("message").value = "";
console.log(res);
alert("your message was sent successfully!");
})
.catch(err=>console.log(err));
}
function alertMail(){
alert("your message was sent successfully!");
}
// GAME
document.addEventListener("DOMContentLoaded", function() {
// Define the number of bubbles to create
const NUM_BUBBLES = 10;
// Create an array to hold the bubbles
let bubbles = [];
// Get the dimensions of the screen
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
// Create the bubbles
for (let i = 0; i < NUM_BUBBLES; i++) {
let bubble = document.createElement("div");
bubble.classList.add("bubble");
// Set random position within the screen space
const bubbleSize = 50; // Assuming the bubble size is 50x50 pixels
const randomX = Math.floor(Math.random() * (screenWidth - bubbleSize));
const randomY = Math.floor(Math.random() * (screenHeight - bubbleSize));
bubble.style.top = randomY + "px";
bubble.style.left = randomX + "px";
document.getElementById("bubble-container").appendChild(bubble);
bubbles.push(bubble);
}
// Set initial position and velocity
var x = 0; // initial x position
var y = 0; // initial y position
var vx = 2; // velocity along x-axis
var vy = 2; // velocity along y-axis
// Update the position of the bubble
function updateBubblePosition() {
// Update the position
x += vx;
y += vy;
// Check if the bubble hit the edges
if (x + bubble.offsetWidth >= window.innerWidth || x <= 0) {
vx *= -1; // reverse velocity along x-axis
}
if (y + bubble.offsetHeight >= window.innerHeight || y <= 0) {
vy *= -1; // reverse velocity along y-axis
}
// Set the new position
bubble.style.left = x + 'px';
bubble.style.top = y + 'px';
// Call the updateBubblePosition function again
requestAnimationFrame(updateBubblePosition);
}
// Start the animation
updateBubblePosition();
});