-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
55 lines (48 loc) · 1.98 KB
/
script.js
File metadata and controls
55 lines (48 loc) · 1.98 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
document.addEventListener('DOMContentLoaded', () => {
const galleryItems = document.querySelectorAll('.gallery-item');
const modal = document.getElementById('image-modal');
const modalImg = modal.querySelector('.modal-content');
const closeModalButton = modal.querySelector('.modal-close-button');
const bubblesContainer = document.querySelector('.domains-bubbles');
if (modal && modalImg && closeModalButton && galleryItems.length > 0) {
const openModal = (src) => {
modalImg.src = src;
modal.classList.add('active');
document.body.classList.add('modal-open');
};
const closeModal = () => {
modal.classList.remove('active');
document.body.classList.remove('modal-open');
};
galleryItems.forEach(item => {
item.addEventListener('click', () => {
const imgSrc = item.dataset.src;
if (imgSrc) openModal(imgSrc);
});
});
modal.addEventListener('click', (e) => {
if (e.target === modal) {
closeModal();
}
});
closeModalButton.addEventListener('click', closeModal);
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && modal.classList.contains('active')) {
closeModal();
}
});
}
if (bubblesContainer) {
for (let i = 0; i < 50; i++) {
const bubble = document.createElement('span');
const size = (Math.random() * 25) + 10;
bubble.style.width = `${size}px`;
bubble.style.height = `${size}px`;
bubble.style.left = `${Math.random() * 100}vw`;
bubble.style.animationDuration = `${(Math.random() * 10) + 15}s`;
bubble.style.animationDelay = `${Math.random() * 5}s`;
bubble.className = Math.random() > 0.5 ? 'blue' : 'pink';
bubblesContainer.appendChild(bubble);
}
}
});