-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
127 lines (95 loc) · 2.85 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
console.log("connected");
let button = document.querySelector(".mobile-btn");
let header = document.querySelector(".header");
const toggleNavbar = () => {
header.classList.toggle("active");
};
button.addEventListener("click", () => toggleNavbar());
let p_btns = document.querySelector(".p-btns");
let p_btn = document.querySelectorAll(".p-btn");
let img_overlay = document.querySelectorAll(".img-overlay");
p_btns.addEventListener("click", (e) => {
let clicked_Btn = e.target;
console.log(`clicked ${clicked_Btn}`);
p_btn.forEach((curElem) => {
curElem.classList.remove("p-btn-active");
});
clicked_Btn.classList.add("p-btn-active");
let btn_num = clicked_Btn.dataset.btnNum;
console.log(btn_num);
let active_img = document.querySelectorAll(`.p-btn--${btn_num}`);
img_overlay.forEach((curElem) => {
curElem.classList.add("p-img-not-active");
});
active_img.forEach((curElem) => {
curElem.classList.remove("p-img-not-active");
});
});
// Swiper JS code
var swiper = new Swiper(".mySwiper", {
slidesPerView: 2,
spaceBetween: 40,
autoplay: {
Delay: 2500,
disableOnInteraction: false,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
// Scroll to TOP Button
const footerElem = document.querySelector(".section-footer");
const scrollElement = document.createElement("div");
scrollElement.classList.add("scrollTop-style");
scrollElement.innerHTML = `<ion-icon name="arrow-up-outline" class="scroll-up"></ion-icon>`;
footerElem.after(scrollElement);
const Header = document.querySelector(".header");
const ScrollToTop = () => {
header.scrollIntoView({ behavior: "smooth" });
};
scrollElement.addEventListener("click", ScrollToTop);
// SMooth Scrolling
const portfolio = document.querySelector(".portfolio");
const contact = document.querySelector(".contact");
document.querySelector(".portfolio-link").addEventListener("click", (e) => {
e.preventDefault();
portfolio.scrollIntoView({ behavior: "smooth" });
});
document.querySelector(".contact-link").addEventListener("click", (e) => {
e.preventDefault();
contact.scrollIntoView({ behavior: "smooth" });
});
const myJsmedia = (widthSize) => {
if (widthSize.matches) {
new Swiper(".mySwiper", {
slidesPerView: 1,
spaceBetween: 40,
autoplay: {
Delay: 2500,
disableOnInteraction: false,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
} else {
new Swiper(".mySwiper", {
slidesPerView: 2,
spaceBetween: 40,
autoplay: {
Delay: 2500,
disableOnInteraction: false,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
}
};
const widthSize = window.matchMedia("(max-width:750px)");
// at run time
myJsmedia(widthSize);
widthSize.addEventListener("change", myJsmedia);