Do something when the menu opens / closes


#1

I’d like to hide the status bar when the side menu opens, and show it again when it closes. To which event do I attach these functions, and where do I put them?


#2

Looking at the source code, there doesn’t appear to be any events to hook into.

I got around this by using the same logic that the Menu class uses to ‘close’ itself, which is just listening for a click on the content window. The code goes in the ngAfterViewInit method so it’s called after we know the menu is created:

ngAfterViewInit() {
    this.myMenu = this.app.getComponent('my-menu');

    this.myMenu.getContentElement().addEventListener('click', ()=>{
        if(this.myMenu.isOpen)
            //do some stuff here          
    }); 
}