-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
89 lines (79 loc) · 2.41 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
// Function to fetch and insert SVG content
function fetchAndInsertSVG(containerId, svgPath) {
fetch(svgPath)
.then(response => response.text())
.then(svgData => {
document.getElementById(containerId).innerHTML = svgData;
})
.catch(error => console.error('Error loading SVG:', error));
}
fetchAndInsertSVG('swim-svg-1', './assets/swim.svg');
fetchAndInsertSVG('swim-svg-2', './assets/swim.svg');
// Page gallery slick slider
$(document).ready(function() {
$('.page-gallery').slick({
slidesToShow: 4,
slidesToScroll: 3,
dots: false,
arrows: false,
infinite: false,
variableWidth: true,
responsive: [
{
breakpoint: 980,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
}
},
{
breakpoint: 780,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
}
},
{
breakpoint: 420,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
// Footer wave animates on scroll
function isWaveInViewport(el) {
var rect = el.getBoundingClientRect(),
vWidth = window.innerWidth || document.documentElement.clientWidth,
vHeight = window.innerHeight || document.documentElement.clientHeight,
efp = function (x, y) { return document.elementFromPoint(x, y) };
// Return false if it's not in the viewport
if (rect.right < 0 || rect.bottom < 0 || rect.left > vWidth || rect.top > vHeight)
return false;
return (
el.contains(efp(rect.left, rect.top)) || el.contains(efp(rect.right, rect.top)) ||
el.contains(efp(rect.right, rect.bottom)) || el.contains(efp(rect.left, rect.bottom))
);
}
// Lightbox JS
let pages = document.querySelectorAll(".page-gallery .page");
let lightbox = document.querySelector(".lightbox");
let selectedPage = lightbox.querySelector(".page");
let close = lightbox.querySelector(".close");
pages.forEach(page => {
page.addEventListener('click', function() {
lightbox.setAttribute('aria-hidden', 'false');
let clickedSrc = page.getAttribute('src');
selectedPage.setAttribute('src', clickedSrc);
});
});
close.addEventListener('click', function() {
lightbox.setAttribute('aria-hidden', 'true');
});
window.addEventListener('click', function(event) {
if (event.target.classList.contains('lightbox')) {
lightbox.setAttribute('aria-hidden', 'true');
}
});