-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (36 loc) · 1.18 KB
/
Copy pathscript.js
File metadata and controls
43 lines (36 loc) · 1.18 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
// SCROLL ANIMATION
const elements = document.querySelectorAll('.fade');
const observer = new IntersectionObserver(entries=>{
entries.forEach(entry=>{
if(entry.isIntersecting){
entry.target.classList.add('show');
}
});
});
elements.forEach(el=>observer.observe(el));
// VIDEO HOVER PLAY
document.querySelectorAll('.card video').forEach(video=>{
video.addEventListener('mouseover',()=>video.play());
video.addEventListener('mouseout',()=>video.pause());
});// VIDEO POPUP
const popup = document.getElementById("videoPopup");
const popupVideo = document.getElementById("popupVideo");
const closeBtn = document.querySelector(".close-btn");
document.querySelectorAll(".card").forEach(card => {
card.addEventListener("click", () => {
const videoSrc = card.getAttribute("data-video");
popupVideo.src = videoSrc;
popup.classList.add("active");
popupVideo.play();
});
});
closeBtn.addEventListener("click", () => {
popup.classList.remove("active");
popupVideo.pause();
});
popup.addEventListener("click", (e) => {
if(e.target === popup){
popup.classList.remove("active");
popupVideo.pause();
}
});