-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
65 lines (51 loc) · 1.94 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
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry)
if (entry.isIntersecting ) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
});
});
const hiddenElements = document.querySelectorAll('.hidden1');
hiddenElements.forEach((el) => observer.observe(el));
const observer1 = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry)
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
});
});
const hiddenElements1 = document.querySelectorAll('.hidden2');
hiddenElements1.forEach((el) => observer1.observe(el));
const observer2 = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry)
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
});
});
const hiddenElements2 = document.querySelectorAll('.hidden3');
hiddenElements2.forEach((el) => observer2.observe(el));
let scrollContainer = document.querySelector(".gallery");
let backBtn = document.getElementById("backbutton");
let nextBtn = document.getElementById("nextbutton");
scrollContainer.addEventListener("wheel", (evt)=>{
// evt.preventDefault();
scrollContainer.scrollleft += evt.deltaY;
});
nextBtn.addEventListener("click", ()=>{
scrollContainer.style.scrollBehavior = "smooth";
scrollContainer.scrollLeft += 370;
});
backBtn.addEventListener("click", ()=>{
scrollContainer.style.scrollBehavior = "smooth";
scrollContainer.scrollLeft -= 370;
});