-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
49 lines (38 loc) · 1.62 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
document.addEventListener('DOMContentLoaded', () => {
// Draggable Notes
const notes = document.querySelectorAll('.note');
notes.forEach(note => {
note.addEventListener('mousedown', (e) => {
let shiftX = e.clientX - note.getBoundingClientRect().left;
let shiftY = e.clientY - note.getBoundingClientRect().top;
function moveAt(pageX, pageY) {
note.style.left = pageX - shiftX + 'px';
note.style.top = pageY - shiftY + 'px';
}
moveAt(e.pageX, e.pageY);
function onMouseMove(event) {
moveAt(event.pageX, event.pageY);
}
document.addEventListener('mousemove', onMouseMove);
note.addEventListener('mouseup', () => {
document.removeEventListener('mousemove', onMouseMove);
});
note.addEventListener('mouseleave', () => {
document.removeEventListener('mousemove', onMouseMove);
});
note.ondragstart = () => false;
});
});
// Heart Falling Animation
const heartsContainer = document.getElementById('hearts-container');
for (let i = 0; i < 20; i++) { // You can adjust the number of hearts
const heart = document.createElement('div');
heart.classList.add('heart');
heart.style.left = Math.random() * 100 + 'vw';
heart.style.animationDelay = Math.random() * 2 + 's';
heartsContainer.appendChild(heart);
}
setTimeout(() => {
heartsContainer.classList.add('hide-hearts');
}, 5000); // Remove hearts after 5 seconds
});