Skip to content

Commit

Permalink
fix navigation for touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
seibtph committed Oct 9, 2020
1 parent 34bd9d4 commit 22d2206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/Resources/public/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
function is_touch_device() {
return !!('ontouchstart' in window // works on most browsers
|| navigator.maxTouchPoints); // works on IE10/11 and Surface
};

jQuery.noConflict();
jQuery(document).ready(function ($) {

Expand Down Expand Up @@ -219,9 +224,7 @@ jQuery(document).ready(function ($) {

$(".sidenav").sidenav();

var touch = matchMedia('(hover: none)').matches;

if(touch == false) {
if(is_touch_device() == false) {
$("nav:not(.subnav) .desktop-menu a.dropdown-button").dropdown({
inDuration: 300,
outDuration: 225,
Expand Down Expand Up @@ -267,7 +270,7 @@ jQuery(document).ready(function ($) {
closeOnClick: false
});

$("a.dropdown-button").click( function() {
$("nav:not(.subnav)").on("touchstart","a.dropdown-button", function(e) {
if( $(this).hasClass("open") ) {
window.location.href = $(this).attr('href');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/js/theme.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 22d2206

Please sign in to comment.