File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ @implements IDisposable
2+ @namespace Blazor.AdminLte
3+
4+ @inject IJSRuntime js
5+
6+ @inject NavigationManager NavigationManager
7+ <!-- Use outer div's id in JavaScript/jQuery to show/hide overlay -->
8+ <div id =" overlay-container" style =" height : 100% ;
9+ width : 100% ;
10+ position : absolute ;
11+ z-index : 1340 ;
12+ top : 0 ;
13+ left : 0 ;
14+ overflow-y : auto ;
15+ overflow-x : auto ;
16+ background-color : #e9ecef
17+ " >
18+ <div class =" overlay-content" >
19+ @ChildContent
20+ </div >
21+ </div >
22+ @code {
23+ [Parameter ]
24+ public RenderFragment ChildContent { get ; set ; }
25+
26+
27+ protected override void OnInitialized ()
28+ {
29+ // Subscribe to the event
30+ NavigationManager .LocationChanged += LocationChanged ;
31+ base .OnInitialized ();
32+ }
33+ void LocationChanged (object sender , LocationChangedEventArgs e )
34+ {
35+ js .InvokeVoidAsync (" overlay" , false );
36+ }
37+ void IDisposable .Dispose ()
38+ {
39+ // Unsubscribe from the event when our component is disposed
40+ NavigationManager .LocationChanged -= LocationChanged ;
41+ }
42+
43+
44+ protected override Task OnAfterRenderAsync (bool firstRender )
45+ {
46+ js .InvokeVoidAsync (" overlay" , true );
47+ return base .OnAfterRenderAsync (firstRender );
48+ }
49+ }
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ function setTitle(title) {
5656 document . title = title ;
5757}
5858
59+ function overlay ( isActive ) {
60+ if ( isActive ) {
61+ $ ( "body" ) . css ( "overflow-y" , "hidden" ) ;
62+ }
63+ else {
64+ $ ( "body" ) . css ( "overflow-y" , "auto" ) ;
65+ }
66+ }
67+
5968function sideBarFixed ( isFixed )
6069{
6170 if ( isFixed ) {
You can’t perform that action at this time.
0 commit comments