-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
141 lines (126 loc) · 3.34 KB
/
script.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
135
136
137
138
139
140
141
// FIT TEXT
$(".banner").fitText();
// SCROLL BEHAVIOUR
// go to top smooth
function topFunction() {
window.scrollTo({top: 0, behavior: 'smooth'});
}
// shrink header when scroll
$(document).on("scroll", function(){
if ($(document).scrollTop() > 30){
$("header").addClass("shrink");
} else {
$("header").removeClass("shrink");
}
});
// COPY TO CLIPBOARD
//var clipboard = new ClipboardJS('.coordinates');
// MOBILE MENU
/*
* Toggles on and off the 'active' class on the menu
* and the toggler button.
*/
function toggle() {
var element = document.getElementById("toggler");
var menu = document.getElementById('menu');
element.classList.toggle("active");
menu.classList.toggle("active");
};
// LOGO SWIPER
var swiper1 = new Swiper('.logoSwiper', {
slidesPerView: 2,
spaceBetween: 10,
loop: true,
speed: 6000,
autoplay: {
delay: 1,
disableOnInteraction: false,
},
breakpoints: {
480: {
slidesPerView: 3,
},
640: {
slidesPerView: 4,
},
1024: {
slidesPerView: 5,
},
1536: {
slidesPerView: 6,
},
},
});
// MATERIAL SWIPER
var swiper2 = new Swiper('.materialSwiper', {
slidesPerView: 2,
spaceBetween: 20,
loop: true,
speed: 1000,
autoplay: {
delay: 3000,
},
breakpoints: {
640: {
slidesPerView: 3,
},
1536: {
slidesPerView: 4,
},
},
});
// MAPBOX
mapboxgl.accessToken = 'pk.eyJ1IjoiaWFtbW0iLCJhIjoiY2wwM3lscmd0MGdyNjNpbWp0YjBjbGE1OCJ9.h6EMCPIzYj4tCMEqgjQRsQ';
const map = new mapboxgl.Map({
container: 'map',
zoom: 10.5,
center: [12.3747329,51.3406321], // x,y coordinates
style: 'mapbox://styles/iammm/cl06qg049000415p304moodap',
cooperativeGestures: true // ctrl + scroll = zoom
});
map.scrollZoom.disable();
map.addControl(new mapboxgl.NavigationControl());
//map.addControl(new mapboxgl.FullscreenControl());
map.on('click', (event) => {
// If the user clicked on one of your markers, get its information.
const features = map.queryRenderedFeatures(event.point, {
layers: ['materialbuffet-locations']
});
if (!features.length) {
return;
}
const feature = features[0];
// Create a popup, specify its options and properties, and add it to the map.
const popup = new mapboxgl.Popup({ offset: [0, -15] })
.setLngLat(feature.geometry.coordinates)
.setHTML(
`<h1>${feature.properties.title}</h1>
<h2>Adresse</h2><p>${feature.properties.adress}</p>
<h2>Öffnungszeiten</h2><p>${feature.properties.open}</p>
<h2>ÖPNV</h2><p>${feature.properties.öpnv}</p>`
)
.addTo(map);
});
var x_offset = 0.002;
var y_offset = 0.0018;
document.getElementById('menu-item-280').addEventListener('click', () => {
map.flyTo({
center: [12.3747329, 51.3406321],
zoom: 10.5,
essential: true // this animation is considered essential with respect to prefers-reduced-motion
});
});
document.getElementById('markt').addEventListener('click', () => {
map.flyTo({
center: [12.316132 + x_offset, 51.315969 + y_offset],
zoom: 15,
essential: true // this animation is considered essential with respect to prefers-reduced-motion
});
});
document.getElementById('lager').addEventListener('click', () => {
map.flyTo({
center: [12.316037 - x_offset, 51.378073 + y_offset],
zoom: 14,
essential: true // this animation is considered essential with respect to prefers-reduced-motion
});
});