* Toggles menu.
()
| 227 | * Toggles menu. |
| 228 | */ |
| 229 | toggleMenu () { |
| 230 | this._menuVisible = !this._menuVisible |
| 231 | |
| 232 | if (this._menuVisible) { |
| 233 | // append menu and trigger next cycle |
| 234 | this._$header.appendChild(this._$menu) |
| 235 | this._$menu.getBoundingClientRect() |
| 236 | |
| 237 | // show menu animated |
| 238 | this._$menu.classList.add('menu--visible') |
| 239 | |
| 240 | // listen to the next window click to hide the menu again |
| 241 | window.requestAnimationFrame(() => { |
| 242 | window.addEventListener('click', this._menuHideHandler) |
| 243 | }) |
| 244 | } else { |
| 245 | // remove menu |
| 246 | this._$header.removeChild(this._$menu) |
| 247 | |
| 248 | // remove listener |
| 249 | window.removeEventListener('click', this._menuHideHandler) |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * Updates Brick status and message. |