-
Notifications
You must be signed in to change notification settings - Fork 0
/
grt-responsive-menu.js
executable file
·51 lines (45 loc) · 1.17 KB
/
grt-responsive-menu.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
/*!
* GRT Responsive Menu - jQuery Plugin
* Version: 1.0
* Author: GRT107
*
* Copyright (c) 2018 GRT107
* Released under the MIT license
*/
// Create a function for mobile version
(function( $ ){
$.fn.grtmobile = function () {
if ($(window).width() < 768) {
$('.grt-mobile-button').on('click', function(){
$(this).toggleClass("grt-mobile-button-open");
$("ul.grt-menu").toggleClass("open-grt-menu ");
$("html, body").toggleClass("body-overflow");
});
$('li.grt-dropdown').on('click', function(e){
$(this).toggleClass("active-dropdown");
});
}
}
})( jQuery );
// Initialize and check for mobile
$.fn.grtmobile();
// On resize window check for mobile
var resizeTimeout;
$(window).resize(function(){
if(!!resizeTimeout){ clearTimeout(resizeTimeout); }
resizeTimeout = setTimeout(function(){
$.fn.grtmobile();
},200);
});
// Add shadow on scroll after 60px
$(window).scroll(function(e){
if ($(this).scrollTop() > 60){
$('header').addClass('scrolled');
} else {
$('header').removeClass('scrolled');
}
});
// Prevent a href clicks on dropdown category
$('li.grt-dropdown > a').on('click', function(e){
e.preventDefault();
});