-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
60 lines (52 loc) · 1.62 KB
/
Copy pathapp.js
File metadata and controls
60 lines (52 loc) · 1.62 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
$(document).ready(() => {
const scrollToTopButton = $('.scroll-to-top');
const showButton = (show) => {
if(!show) {
scrollToTopButton.fadeOut(200, "swing", () => {
scrollToTopButton.removeClass('show-flex');
});
return;
}
scrollToTopButton.fadeIn(200, "swing", () => {
scrollToTopButton.addClass('show-flex');
});
};
document.addEventListener('scroll', () => {
if(globalThis.scrollY > 300) {
showButton(true);
} else {
showButton(false);
}
});
scrollToTopButton.on(
'click', () => {
globalThis.scrollTo({
top: 0,
behavior: 'smooth'
});
}
);
const modal = $('#screenshotModal');
const modalImg = modal.find('img');
const modalClose = modal.find('.modal-close');
$('.screenshots img').on('click', function() {
const fullSrc = $(this).data('full');
modalImg.attr('src', fullSrc);
modal.addClass('active').attr('aria-hidden', 'false');
$('body').css('overflow', 'hidden');
});
modalClose.on('click', closeModal);
modal.on('click', function(e) {
if(e.target === modal[0]) closeModal();
});
$(document).on('keydown', (event) => {
if(event.key === 'Escape' && modal.hasClass('active')) {
closeModal();
}
});
function closeModal() {
modal.removeClass('active').attr('aria-hidden', 'true');
$('body').css('overflow', '');
setTimeout(() => modalImg.attr('src', ''), 200);
}
});