Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
168 lines (132 loc) · 4.37 KB
/
Copy pathscript.js
File metadata and controls
168 lines (132 loc) · 4.37 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Toggling Skill Tabs
const tabs = document.querySelectorAll('[data-target]');
const tabContent = document.querySelectorAll('[data-content]');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = document.querySelector(tab.dataset.target);
tabContent.forEach(tabContents => {
tabContents.classList.remove('skills-active');
})
target.classList.add('skills-active');
tabs.forEach(tab => {
tab.classList.remove('skills-active');
})
tab.classList.add('skills-active');
})
})
//Mix it up Sorting
let mixerPortfolio = mixitup('.work-container', {
selectors: {
target: '.work-card'
},
animation: {
duration: 300
}
});
// Active link changing
const linkWork = document.querySelectorAll('.work-item');
function activeWork() {
linkWork.forEach(l => l.classList.remove('active-work'))
this.classList.add('active-work')
}
linkWork.forEach(l => l.addEventListener('click', activeWork));
//Portfolio Popup
document.addEventListener('click', (e) => {
if(e.target.classList.contains('work-button')){
togglePortfolioPopup();
portfolioItemDetails(e.target.parentElement);
}
})
function togglePortfolioPopup() {
document.querySelector('.portfolio-popup').classList.toggle('open');
}
document.querySelector('.portfolio-popup-close').addEventListener('click', togglePortfolioPopup);
function portfolioItemDetails(portfolioItem) {
document.querySelector('.pp-thumbnail img').src = portfolioItem.querySelector('.work-img').src;
document.querySelector('.portfolio-popup-subtitle span').innerHTML = portfolioItem.querySelector('.work-title').innerHTML;
document.querySelector('.portfolio-popup-body').innerHTML = portfolioItem.querySelector('.portfolio-item-details').innerHTML;
}
//Services Popup
const modalViews = document.querySelectorAll('.services-modal');
const modelBtns = document.querySelectorAll('.services-button');
const modalCloses = document.querySelectorAll('.services-modal-close');
let modal = function(modalClick) {
modalViews[modalClick].classList.add('active-modal');
}
modelBtns.forEach((modelBtn, i) => {
modelBtn.addEventListener('click', () => {
modal(i);
})
})
modalCloses.forEach((modalClose) => {
modalClose.addEventListener('click', () => {
modalViews.forEach((modalView) => {
modalView.classList.remove('active-modal');
})
})
})
//Swiper Testimonial
let swiper = new Swiper(".testimonials-container", {
spaceBetween: 24,
loop: true,
grabCursor: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
breakpoints: {
576: {
slidesPerView: 2,
},
768: {
slidesPerView: 2,
spaceBetween: 48,
},
},
});
// Input Animation
const inputs = document.querySelectorAll('.input');
function focusFunc() {
let parent = this.parentNode;
parent.classList.add('focus');
}
function blurFunc() {
let parent = this.parentNode;
if(this.value == "") {
parent.classList.remove('focus');
}
}
inputs.forEach((input) => {
input.addEventListener('focus', focusFunc);
input.addEventListener('blur', blurFunc);
})
// Scroll Section Active Link
const sections = document.querySelectorAll('section[id]');
window.addEventListener('scroll', navHighlighter);
function navHighlighter() {
let scrollY = window.pageYOffset;
sections.forEach(current => {
const sectionHeight = current.offsetHeight;
const sectionTop = current.offsetTop - 50;
const sectionId = current.getAttribute('id');
if(scrollY > sectionTop && scrollY <= sectionTop + sectionHeight) {
document.querySelector('.nav-menu a[href*=' + sectionId + ']').classList.add('active-link');
}else {
document.querySelector('.nav-menu a[href*=' + sectionId + ']').classList.remove('active-link');
}
})
}
// Activating Sidebar
const navMenu = document.getElementById('sidebar');
const navToggle = document.getElementById('nav-toggle');
const navClose = document.getElementById('nav-close');
if(navToggle) {
navToggle.addEventListener('click', () => {
navMenu.classList.add('show-sidebar');
})
}
if(navClose) {
navClose.addEventListener('click', () => {
navMenu.classList.remove('show-sidebar');
})
}