Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Heusschen committed May 19, 2019
1 parent baac45d commit 1f2b084
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 64 deletions.
21 changes: 17 additions & 4 deletions bin/mburger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* mburger webcomponent v1.3.2
* mburger webcomponent v1.3.3
* mmenujs.com/mburger
*
* Copyright (c) Fred Heusschen
Expand Down Expand Up @@ -31,25 +31,38 @@ customElements.define('m-burger', class extends HTMLElement {
}
attributeChangedCallback(name, oldValue, newValue) {
if (name == 'menu') {
// Set the new menu node and API.
// Initiate the new menu.
this.initMenu(newValue);
}
}
connectedCallback() {
// Open the menu when clicking the hamburger.
this.addEventListener('click', evnt => {
// If there is no API for a menu available (the menu isn't yet initiated),
// try to initiate the menu.
if (!this.menuApi) {
this.initMenu();
}
// If there is an API for a menu available,
// open the menu.
if (this.menuApi && this.menuApi.open) {
this.menuApi.open();
}
});
}
/**
* Set the menu node and API.
* @param {string} id The ID-attribute for the menu node.
* @param {string} [id] The ID-attribute for the menu node.
*/
initMenu(id) {
this.menuNode = id ? document.getElementById(id) : null;
this.menuNode = null;
this.menuApi = null;
if (!id) {
id = this.getAttribute('menu');
}
if (id) {
this.menuNode = document.getElementById(id);
}
if (this.menuNode) {
this.menuApi =
this.menuNode['mmApi'] || this.menuNode['mmenu'] || null;
Expand Down
2 changes: 1 addition & 1 deletion bin/webcomponent.css

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

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mburger-css",
"version": "1.3.2",
"version": "1.3.3",
"authors": "Fred Heusschen <info@mmenujs.com>",
"license": "CC-BY-4.0",
"description": "A small collection of CSS animated hamburgers. All set up to work out of the box with the mmenu.js plugin.",
Expand Down
2 changes: 1 addition & 1 deletion dist/mburger.css

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

Loading

0 comments on commit 1f2b084

Please sign in to comment.