arkon / ng-sidebar

[Inactive] Angular sidebar component.
https://echeung.me/ng-sidebar
MIT License
388 stars 136 forks source link

Intercept click on Backdrop #151

Open panagulis72 opened 6 years ago

panagulis72 commented 6 years ago

Hi, I'm using Angular 6 and RxJS6. I'm saving into the application Store a boolean, 'isSidenavOpened'. All works fine, but I enabled the backdrop and I'm not able to intercept the click on it. In fact, I would like to set the 'isSidenavOpened' variable to false

arkon commented 6 years ago

There's output events that tell you when the sidebar has opened or closed, so you probably don't need to intercept the click on the backdrop.

panagulis72 commented 6 years ago

I used onCloseStart, but if I close the sidebar clicking on the backdrop it dispatch two actions of type "CLOSE_SIDEBAR". So it works, even if it is dispatched twice:

`<ng-sidebar [(opened)]="isMainMenuSidebarOpened" mode="over" keyClose="true" position="left" closeOnClickBackdrop="true" showBackdrop="true" animate="true" trapFocus="true" autoFocus="true" sidebarClass="main-menu-sidebar" ariaLabel="Menu" (onCloseStart)="onMainMenuSidenavClose()">

` app.component.ts: ` onMainMenuSidenavClose(): void { this.store.dispatch(new CoreActions.CloseMainMenuSidebar()); }` If I click the button that close the sidenav (and call the function onMainMenuSidenavClose()) the action is dispatched just one time. So, it was just for code cleaning. The ng-sidebar component has many interesting features, it really has everything (good job), but it would not bad to add the ability to intercept the click on the backdrop. Could be useful to someone, even more than me! Thank you!