File size: 776 Bytes
1a11305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const images = [...document.querySelectorAll('.image')];

// popup

const popup = document.querySelector('.popup');
const closeBtn = document.querySelector('.close-btn');
const largeImage = document.querySelector('.large-image');


popup.addEventListener('click', (e) => {

    const bound = largeImage.getBoundingClientRect();
    const x = e.clientX;
    const y = e.clientY;

    if (!(x >= bound.left && x <= bound.right &&
        y >= bound.top && y <= bound.bottom)) {
        popup.classList.toggle('active');u
    }
});

images.forEach((item, i) => {
    item.addEventListener('click', () => {

        largeImage.src = item.src;
        popup.classList.toggle('active');
    })
})


closeBtn.addEventListener('click', () => {
    popup.classList.toggle('active');
})