Close small menu when user clicks outside #1375
This commit is contained in:
parent
15b7f3bb39
commit
29b0bb311f
1 changed files with 11 additions and 0 deletions
|
@ -42,6 +42,17 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Close small menu when user clicks outside
|
||||||
|
document.addEventListener( 'click', function( event ) {
|
||||||
|
var isClickInside = container.contains( event.target );
|
||||||
|
|
||||||
|
if ( ! isClickInside ) {
|
||||||
|
container.className = container.className.replace( ' toggled', '' );
|
||||||
|
button.setAttribute( 'aria-expanded', 'false' );
|
||||||
|
menu.setAttribute( 'aria-expanded', 'false' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
// Get all the link elements within the menu.
|
// Get all the link elements within the menu.
|
||||||
links = menu.getElementsByTagName( 'a' );
|
links = menu.getElementsByTagName( 'a' );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue