/// <inheritdoc/> protected override async Task OnFirstAfterRenderAsync() { dotNetObjectRef ??= CreateDotNetObjectRef(new BreakpointActivatorAdapter(this)); await JSBreakpointModule.RegisterBreakpoint(dotNetObjectRef, ElementId); if (Mode != BarMode.Horizontal) { // Check if we need to collapse the Bar based on the current screen width against the breakpoint defined for this component. // This needs to be run to set the initial state, RegisterBreakpointComponent and OnBreakpoint will handle // additional changes to responsive breakpoints from there. isBroken = BreakpointActivatorAdapter.IsBroken(Breakpoint, await JSBreakpointModule.GetBreakpoint()); if (isBroken) { initial = false; await Toggle(); } else if (initial) { initial = false; DirtyClasses(); await InvokeAsync(StateHasChanged); } } await base.OnFirstAfterRenderAsync(); }
protected override async Task OnFirstAfterRenderAsync() { dotNetObjectRef ??= JSRunner.CreateDotNetObjectRef(new BreakpointActivatorAdapter(this)); if (Rendered) { _ = JSRunner.RegisterBreakpointComponent(dotNetObjectRef, ElementId); if (Mode != BarMode.Horizontal) { // Check if we need to collapse the Bar based on the current screen width against the breakpoint defined for this component. // This needs to be run to set the inital state, RegisterBreakpointComponent and OnBreakpoint will handle // additional changes to responsive breakpoints from there. isBroken = BreakpointActivatorAdapter.IsBroken(Breakpoint, await JSRunner.GetBreakpoint()); if (Visible == isBroken) { Visible = !isBroken; StateHasChanged(); } } } await base.OnFirstAfterRenderAsync(); }
/// <summary> /// An event that fires when the navigation location has changed. /// </summary> /// <param name="sender">Object the fired the notification.</param> /// <param name="args">New location arguments.</param> private async void OnLocationChanged(object sender, LocationChangedEventArgs args) { // Collapse the bar automatically if (Visible && BreakpointActivatorAdapter.IsBroken(NavigationBreakpoint, await JSRunner.GetBreakpoint())) { await Toggle(); } }
protected override async Task OnInitializedAsync() { if (Mode != BarMode.Horizontal) { lastBrokenState = BreakpointActivatorAdapter.IsBroken(Breakpoint, await JSRunner.GetBreakpoint()); Visible = !lastBrokenState; } if (NavigationBreakpoint != Breakpoint.None) { NavigationManager.LocationChanged += OnLocationChanged; } await base.OnInitializedAsync(); }