Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

open menu @ media query #189

Open
stelco opened this issue Aug 10, 2018 · 0 comments
Open

open menu @ media query #189

stelco opened this issue Aug 10, 2018 · 0 comments

Comments

@stelco
Copy link

stelco commented Aug 10, 2018

Hi, I want to be able to open the menu at a certain media query but am wondering how i would achieve this.
Currently using the following which is a click function to load the menu.

new mlPushMenu(document.getElementById('mp-menu'), document.getElementById('trigger'), {
type: 'cover'

I want to be able to execute mlPushMenu <768px. As follows...

// media query event handler
if (matchMedia) {
const mq = window.matchMedia("(max-width: 768px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
// media query change
function WidthChange(mq) {
if (mq.matches) {
alert("hello im less than 768px");
// open slider menu here
}
}

Can anyone advise? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant