-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
134 lines (110 loc) · 3.16 KB
/
app.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
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
// Burger Menu
const navSlide = () => {
const burger = document.querySelector('.hamburger-menu');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');
burger.addEventListener('click', () => {
{passive: true};
burger.classList.toggle('no-shadow');
nav.classList.toggle('nav-active');
navLinks.forEach((link, index) => {
if(link.style.animation) {
link.style.animation = '';
} else {
link.style.animation = `navLinkFade .5s ease forwards ${index / 5 + .2}s`;
}
});
burger.classList.toggle('toggle');
navLinks.forEach(link => {
link.addEventListener('click', () => {
burger.click();
link.style.animation = "";
});
});
});
}
navSlide();
//Slide Images About Section
let slideInd = 0;
const autoSlide = () => {
let i;
const slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideInd++;
if (slideInd > slides.length) {
slideInd = 1
}
slides[slideInd-1].style.display = "block";
setTimeout(autoSlide, 3000);
}
autoSlide();
//Slide Images About Section END
// Reviews Carousel effect
let slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName("review-block");
let dots = document.getElementsByClassName("dot");
if (n > slides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = slides.length;
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "flex";
dots[slideIndex-1].className += " active";
}
// Reviews Carousel effect END
// Google Location Map
function myMap() {
let shopLocation = {lat: 51.435400, lng: -0.159940}
let mapInfo = {
center: new google.maps.LatLng(shopLocation),
zoom: 15,
};
let map = new google.maps.Map(document.getElementById('googleMap'),mapInfo);
let marker = new google.maps.Marker({
position: shopLocation,
map: map,
});
}
const lazyLoadMap = (api_key) => {
if (api_key) {
let options = {
rootMargin: '200px',
threshold: 0,
}
let map = document.getElementById('googleMap');
let apiKey = 'AIzaSyDJ69QaDC8N3m3pM3sF5-wZhan1j4GeUIo';
let observer = new IntersectionObserver(
function(entries, self) {
let isIntersecting = typeof entries[0].isIntersecting === 'boolean' ? entries[0].isIntersecting : entries[0].intersectionRatio > 0;
if (isIntersecting) {
let mapsReady = document.createElement('script');
mapsReady.src = 'https://maps.googleapis.com/maps/api/js?key=' + apiKey + '&callback=myMap';
document.body.appendChild(mapsReady);
self.unobserve(map);
}
},
options
)
observer.observe(map)
}
}
lazyLoadMap('AIzaSyDJ69QaDC8N3m3pM3sF5-wZhan1j4GeUIo');
// Google Location Map END