A
A
Anton Golubkov2018-08-05 20:42:49
css
Anton Golubkov, 2018-08-05 20:42:49

How to solve the problem with matchMedia on Android devices?

Got the code from the previous programmer

function setupForWidth(mql) {
        if(mql.matches) {
            menu.classList.remove('hidden');
            document.querySelector('body').classList.remove('mod-position-f')
        } else {
            menu.classList.add('hidden');
            bodyPosition(menu, 'hidden');
        }
    }

    var mql = window.matchMedia("screen and (min-width: 768px)");

    if(menu) {
        mql.addListener(setupForWidth);
        setupForWidth(mql)
    }

all this hangs on DOMContentLoaded
And it works correctly in all browsers except Android Browser. The Android browser ignores the condition and always works out the else option... help me figure it out...
Orby.ru website
When opening from an android device through a native browser, the menu overlaps everything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2018-08-05
@ruvasik

Are you sure your android satisfies the condition and its screen width is greater than 767px?
And what version of Android?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question