-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
310 lines (226 loc) · 6.63 KB
/
main.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
;(function () {
'use strict';
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
var fullHeight = function() {
if ( !isMobile.any() ) {
$('.js-fullheight').css('height', $(window).height());
$(window).resize(function(){
$('.js-fullheight').css('height', $(window).height());
});
}
};
var counter = function() {
$('.js-counter').countTo({
formatter: function (value, options) {
return value.toFixed(options.decimals);
},
});
};
var counterWayPoint = function() {
if ($('#colorlib-counter').length > 0 ) {
$('#colorlib-counter').waypoint( function( direction ) {
if( direction === 'down' && !$(this.element).hasClass('animated') ) {
setTimeout( counter , 400);
$(this.element).addClass('animated');
}
} , { offset: '90%' } );
}
};
// Animations
var contentWayPoint = function() {
var i = 0;
$('.animate-box').waypoint( function( direction ) {
if( direction === 'down' && !$(this.element).hasClass('animated') ) {
i++;
$(this.element).addClass('item-animate');
setTimeout(function(){
$('body .animate-box.item-animate').each(function(k){
var el = $(this);
setTimeout( function () {
var effect = el.data('animate-effect');
if ( effect === 'fadeIn') {
el.addClass('fadeIn animated');
} else if ( effect === 'fadeInLeft') {
el.addClass('fadeInLeft animated');
} else if ( effect === 'fadeInRight') {
el.addClass('fadeInRight animated');
} else {
el.addClass('fadeInUp animated');
}
el.removeClass('item-animate');
}, k * 200, 'easeInOutExpo' );
});
}, 100);
}
} , { offset: '85%' } );
};
var burgerMenu = function() {
$('.js-colorlib-nav-toggle').on('click', function(event){
event.preventDefault();
var $this = $(this);
if ($('body').hasClass('offcanvas')) {
$this.removeClass('active');
$('body').removeClass('offcanvas');
} else {
$this.addClass('active');
$('body').addClass('offcanvas');
}
});
};
// Click outside of offcanvass
var mobileMenuOutsideClick = function() {
$(document).click(function (e) {
var container = $("#colorlib-aside, .js-colorlib-nav-toggle");
if (!container.is(e.target) && container.has(e.target).length === 0) {
if ( $('body').hasClass('offcanvas') ) {
$('body').removeClass('offcanvas');
$('.js-colorlib-nav-toggle').removeClass('active');
}
}
});
$(window).scroll(function(){
if ( $('body').hasClass('offcanvas') ) {
$('body').removeClass('offcanvas');
$('.js-colorlib-nav-toggle').removeClass('active');
}
});
};
var clickMenu = function() {
$('#navbar a:not([class="external"])').click(function(event){
var section = $(this).data('nav-section'),
navbar = $('#navbar');
if ( $('[data-section="' + section + '"]').length ) {
$('html, body').animate({
scrollTop: $('[data-section="' + section + '"]').offset().top - 55
}, 500);
}
if ( navbar.is(':visible')) {
navbar.removeClass('in');
navbar.attr('aria-expanded', 'false');
$('.js-colorlib-nav-toggle').removeClass('active');
}
event.preventDefault();
return false;
});
};
// Reflect scrolling in navigation
var navActive = function(section) {
var $el = $('#navbar > ul');
$el.find('li').removeClass('active');
$el.each(function(){
$(this).find('a[data-nav-section="'+section+'"]').closest('li').addClass('active');
});
};
var navigationSection = function() {
var $section = $('section[data-section]');
$section.waypoint(function(direction) {
if (direction === 'down') {
navActive($(this.element).data('section'));
}
}, {
offset: '150px'
});
$section.waypoint(function(direction) {
if (direction === 'up') {
navActive($(this.element).data('section'));
}
}, {
offset: function() { return -$(this.element).height() + 155; }
});
};
var sliderMain = function() {
$('#colorlib-hero .flexslider').flexslider({
animation: "fade",
slideshowSpeed: 5000,
directionNav: true,
start: function(){
setTimeout(function(){
$('.slider-text').removeClass('animated fadeInUp');
$('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
}, 500);
},
before: function(){
setTimeout(function(){
$('.slider-text').removeClass('animated fadeInUp');
$('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
}, 500);
}
});
};
var stickyFunction = function() {
var h = $('.image-content').outerHeight();
if ($(window).width() <= 992 ) {
$("#sticky_item").trigger("sticky_kit:detach");
} else {
$('.sticky-parent').removeClass('stick-detach');
$("#sticky_item").trigger("sticky_kit:detach");
$("#sticky_item").trigger("sticky_kit:unstick");
}
$(window).resize(function(){
var h = $('.image-content').outerHeight();
$('.sticky-parent').css('height', h);
if ($(window).width() <= 992 ) {
$("#sticky_item").trigger("sticky_kit:detach");
} else {
$('.sticky-parent').removeClass('stick-detach');
$("#sticky_item").trigger("sticky_kit:detach");
$("#sticky_item").trigger("sticky_kit:unstick");
$("#sticky_item").stick_in_parent();
}
});
$('.sticky-parent').css('height', h);
$("#sticky_item").stick_in_parent();
};
var owlCrouselFeatureSlide = function() {
$('.owl-carousel').owlCarousel({
animateOut: 'fadeOut',
animateIn: 'fadeIn',
autoplay: true,
loop:true,
margin:0,
nav:true,
dots: false,
autoHeight: true,
items: 1,
navText: [
"<i class='icon-arrow-left3 owl-direction'></i>",
"<i class='icon-arrow-right3 owl-direction'></i>"
]
})
};
// Document on load.
$(function(){
fullHeight();
counter();
counterWayPoint();
contentWayPoint();
burgerMenu();
clickMenu();
// navActive();
navigationSection();
// windowScroll();
mobileMenuOutsideClick();
sliderMain();
stickyFunction();
owlCrouselFeatureSlide();
});
}());