-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
57 lines (48 loc) · 1.46 KB
/
scripts.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
//Like button function
const like = document.querySelectorAll('.vote img');
like.forEach(like => {
like.addEventListener('click', function(){
if ( like.src.indexOf('like.png') === -1){
like.src = `resources/like.png`
} else {
like.src = `resources/like-black.png`
}
});
});
//Favorite button function
const fav = document.querySelectorAll('.favorite img');
fav.forEach(fav => {
fav.addEventListener('click', function(){
if (fav.src.indexOf('fav.png') === -1){
fav.src = `resources/fav.png`;
} else {
fav.src = `resources/fav-black.png`;
}
});
});
//Makes gallery images full screen
const imgs = document.querySelectorAll('.gallery-img img');
const fullPage = document.querySelector('#fullpage');
imgs.forEach(img => {
img.addEventListener('click', function() {
fullPage.style.backgroundImage = 'url(' + img.src + ')';
fullPage.style.display = 'block';
scrollDisable();
});
});
const closeFullscreen = () => {
fullPage.style.display='none';
scrollEnable();
}
const scrollDisable = () => {
// To get the scroll position of current webpage
TopScroll = window.pageYOffset || document.documentElement.scrollTop;
LeftScroll = window.pageXOffset || document.documentElement.scrollLeft,
// if scroll happens, set it to the previous value
window.onscroll = function() {
window.scrollTo(LeftScroll, TopScroll);
};
}
const scrollEnable = () => {
window.onscroll = function() {};
}