forked from PurohitAakash/Doc-Circle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (30 loc) · 1.15 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
// navbar toggling
const navbarShowBtn = document.querySelector('.navbar-show-btn');
const navbarCollapseDiv = document.querySelector('.navbar-collapse');
const navbarHideBtn = document.querySelector('.navbar-hide-btn');
navbarShowBtn.addEventListener('click', function(){
navbarCollapseDiv.classList.add('navbar-show');
});
navbarHideBtn.addEventListener('click', function(){
navbarCollapseDiv.classList.remove('navbar-show');
});
// changing search icon image on window resize
window.addEventListener('resize', changeSearchIcon);
function changeSearchIcon(){
let winSize = window.matchMedia("(min-width: 1200px)");
if(winSize.matches){
document.querySelector('.search-icon img').src = "images/search-icon.png";
} else {
document.querySelector('.search-icon img').src = "images/search-icon-dark.png";
}
}
changeSearchIcon();
// stopping all animation and transition
let resizeTimer;
window.addEventListener('resize', () =>{
document.body.classList.add('resize-animation-stopper');
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
document.body.classList.remove('resize-animation-stopper');
}, 400);
});