-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteme.js
229 lines (188 loc) · 3.96 KB
/
deleteme.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/* JS Document */
/******************************
[Table of Contents]
1. Vars and Inits
2. Set Header
3. Initialize Hamburger
4. Initialize Parallax
5. Init Google Map
******************************/
$(document).ready(function()
{
"use strict";
/*
1. Vars and Inits
*/
var hamb = $('.hamburger');
var header = $('.header');
var hambActive = false;
var menuActive = false;
var ctrl = new ScrollMagic.Controller();
var map;
setHeader();
$(window).on('resize', function()
{
setHeader();
});
$(document).on('scroll', function()
{
setHeader();
});
initHamburger();
initParallax();
initGoogleMap();
/*
2. Set Header
*/
function setHeader()
{
if(window.innerWidth < 992)
{
if($(window).scrollTop() > 100)
{
header.addClass('scrolled');
}
else
{
header.removeClass('scrolled');
}
}
else
{
if($(window).scrollTop() > 100)
{
header.addClass('scrolled');
}
else
{
header.removeClass('scrolled');
}
}
if(window.innerWidth > 991 && menuActive)
{
closeMenu();
}
}
/*
3. Initialize Hamburger
*/
function initHamburger()
{
if($('.hamburger_container').length)
{
var hamb = $('.hamburger_container');
hamb.on('click', function(event)
{
event.stopPropagation();
if(!menuActive)
{
openMenu();
$(document).one('click', function cls(e)
{
if($(e.target).hasClass('menu_mm'))
{
$(document).one('click', cls);
}
else
{
closeMenu();
}
});
}
else
{
$('.menu_container').removeClass('active');
menuActive = false;
}
});
}
}
function openMenu()
{
var fs = $('.menu_container');
fs.addClass('active');
hambActive = true;
menuActive = true;
}
function closeMenu()
{
var fs = $('.menu_container');
fs.removeClass('active');
hambActive = false;
menuActive = false;
}
/*
4. Init Parallax
*/
function initParallax()
{
// Add parallax effect to home slider
if($('.slider_prlx').length)
{
var homeBcg = $('.slider_prlx');
var homeBcgScene = new ScrollMagic.Scene({
triggerElement: homeBcg,
triggerHook: 1,
duration: "100%"
})
.setTween(TweenMax.to(homeBcg, 1, {y: '15%', ease:Power0.easeNone}))
.addTo(ctrl);
}
// Add parallax effect to every element with class prlx
// Add class prlx_parent to the parent of the element
if($('.prlx_parent').length && $('.prlx').length)
{
var elements = $('.prlx_parent');
elements.each(function()
{
var ele = this;
var bcg = $(ele).find('.prlx');
var slideParallaxScene = new ScrollMagic.Scene({
triggerElement: ele,
triggerHook: 1,
duration: "200%"
})
.setTween(TweenMax.from(bcg, 1, {y: '-30%', ease:Power0.easeNone}))
.addTo(ctrl);
});
}
}
/*
5. Init Google Map
*/
function initGoogleMap()
{
var myLatlng = new google.maps.LatLng(25.498345,-80.352984);
var mapOptions =
{
center: myLatlng,
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true,
scrollwheel: false,
zoomControl: true,
zoomControlOptions:
{
position: google.maps.ControlPosition.RIGHT_CENTER
},
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
rotateControl: false,
fullscreenControl: true,
styles:[]
}
// Initialize a map with options
map = new google.maps.Map(document.getElementById('map'), mapOptions);
map.panBy(-45, 0);
// Re-center map after window resize
google.maps.event.addDomListener(window, 'resize', function()
{
setTimeout(function()
{
google.maps.event.trigger(map, "resize");
map.setCenter(myLatlng);
}, 1400);
});
}
});