Skip to content

Instantly share code, notes, and snippets.

@meetKowshik
Last active October 10, 2019 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meetKowshik/af97c5eb3a8369e7b8417570deaaa6d8 to your computer and use it in GitHub Desktop.
Save meetKowshik/af97c5eb3a8369e7b8417570deaaa6d8 to your computer and use it in GitHub Desktop.
Dropdown Activate in touch device (working for iphone X landscape mode, Ipad and Ipad pro)
$(window).resize(function() {
if($(this).innerWidth() > 800 && $(this).innerWidth() < 1367) {
if(/Ipad/i.test(navigator.userAgent)) {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return false;
}
})
} else if (/Mobi/i.test(navigator.userAgent)) {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return false;
}
})
}
} else {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return true;
}
})
}
})
if($(this).innerWidth() > 800 && $(this).innerWidth() < 1367) {
if(/Ipad/i.test(navigator.userAgent)) {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return false;
}
})
} else if (/Mobi/i.test(navigator.userAgent)) {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return false;
}
})
}
} else {
$('Paste the navigation selector here').on('click', function(e) {
if($(this).hasClass('special class whether this one has submenu or not')) {
return true;
}
})
}
For Wordpress Site
Add a top level menu item for redirecting to the main page for touch device. Add a special class to control the show and hide
$(window).resize(function() {
if($(this).innerWidth() > 991 && $(this).innerWidth() < 1367) {
if(/Ipad/i.test(navigator.userAgent)) {
$('Special top level class').addClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return false;
}
})
} else if (/Mobi/i.test(navigator.userAgent)) {
$('Special top level class').addClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return false;
}
})
}
} else {
$('Special top level class').removeClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return true;
}
})
}
});
if($(this).innerWidth() > 991 && $(this).innerWidth() < 1367) {
if(/Ipad/i.test(navigator.userAgent)) {
$('Special top level class').addClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return false;
}
})
} else if (/Mobi/i.test(navigator.userAgent)) {
$('Special top level class').addClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return false;
}
})
}
} else {
$('Special top level class').removeClass('active');
$('.menu-item a').on('click', function(e) {
if($(this).parent().hasClass('menu-item-has-children')) {
return true;
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment