-
Notifications
You must be signed in to change notification settings - Fork 41
Home
Ed Charbeneau edited this page Jan 22, 2020
·
19 revisions
Welcome to the BlazorSize wiki!
Organize later
@*<script src="_content/BlazorSize/blazorSize.js"></script>*@
<script src="_content/BlazorSize/blazorSize.min.js"></script>
services.AddScoped<ResizeListener>();
//services.AddResizeListener(options =>
// {
// options.ReportRate = 300;
// options.EnableLogging = true;
// options.SuppressInitEvent = true;
// });
@using BlazorPro.BlazorSize
@implements IDisposable
@inject ResizeListener listener
@page "/"
<h3>Height: @browser.Height</h3>
<h3>Width: @browser.Width</h3>
<h3>MQ: @IsSmallMedia</h3>
@code {
BrowserWindowSize browser = new BrowserWindowSize();
bool IsSmallMedia = false;
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
listener.OnResized += WindowResizedA;
}
}
void IDisposable.Dispose()
{
listener.OnResized -= WindowResizedA;
}
async void WindowResizedA(object _, BrowserWindowSize window)
{
browser = window;
IsSmallMedia = await listener.MatchMedia(Breakpoints.XLargeUp);
StateHasChanged();
}
}