-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (42 loc) · 1.39 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
const menu = document.querySelector('#mobile-menu');
const menuLinks = document.querySelector('.navbar__menu');
menu.addEventListener('click', function(){
menu.classList.toggle('is-active');
menuLinks.classList.toggle('active');
});
function initMap(){
var location = {lat: 45.631910, lng: -73.831410};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: location
});
var marker = new google.maps.Marker({
position: location,
map: map
});
}
// Slider
document.addEventListener("DOMContentLoaded", function () {
const slides = document.querySelectorAll(".main__slide");
let currentIndex = 0;
const prevBtn = document.getElementById("previous");
const nextBtn = document.getElementById("next");
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.toggle("active", i === index);
});
}
function nextSlide() {
currentIndex = (currentIndex + 1) % slides.length;
showSlide(currentIndex);
}
function prevSlide() {
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
showSlide(currentIndex);
}
nextBtn.addEventListener("click", nextSlide);
prevBtn.addEventListener("click", prevSlide);
// Auto slide every 3 seconds
setInterval(nextSlide, 3000);
showSlide(currentIndex);
});