From f4bdc66a40ff1b43b7de38c37c698fa144d30be3 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Sun, 7 Aug 2022 15:47:59 +0200 Subject: [PATCH] Simplify the mobile.js. --- assets/js/mobile.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/assets/js/mobile.js b/assets/js/mobile.js index 7e26693..b805e33 100644 --- a/assets/js/mobile.js +++ b/assets/js/mobile.js @@ -7,21 +7,15 @@ 'use strict'; - // Activate the mobil menu for small screens. - if (window.matchMedia && $('.mobile-nav').length) { - var mq = window.matchMedia('(max-width: 999px)'); - if (mq.matches) { - // Toggle the mobile nav sheet. - $('.mobile-nav__cover, .mobile-nav__toggle').handle('click', function () { - $('body').scroll().toggleClass('js-nav-open'); - }); + // Toggle the mobile nav sheet. + $('.mobile-nav__cover, .mobile-nav__toggle').handle('click', function () { + $('body').scroll().toggleClass('js-nav-open'); + }); - // Close the nav sheet after click (needed for anchor links). - $('.mobile-nav__sheet').find('a').on('click', function () { - $('body').removeClass('js-nav-open'); - }); - } - } + // Close the nav sheet after click (needed for anchor links). + $('.mobile-nav__sheet').find('a').on('click', function () { + $('body').removeClass('js-nav-open'); + }); })(u);