Tizzani.BlazorHelpers.BrowserWindow 1.0.0

dotnet add package Tizzani.BlazorHelpers.BrowserWindow --version 1.0.0                
NuGet\Install-Package Tizzani.BlazorHelpers.BrowserWindow -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tizzani.BlazorHelpers.BrowserWindow" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tizzani.BlazorHelpers.BrowserWindow --version 1.0.0                
#r "nuget: Tizzani.BlazorHelpers.BrowserWindow, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tizzani.BlazorHelpers.BrowserWindow as a Cake Addin
#addin nuget:?package=Tizzani.BlazorHelpers.BrowserWindow&version=1.0.0

// Install Tizzani.BlazorHelpers.BrowserWindow as a Cake Tool
#tool nuget:?package=Tizzani.BlazorHelpers.BrowserWindow&version=1.0.0                

Option 1: Use EventCallbacks

@using Tizzani.BlazorHelpers.BrowserWindow.Models

<WindowDimensionsInfo OnResize="UpdateDimensions" />
<PageOffsetInfo OnScroll="UpdatePageOffset" />

@if (Dimensions == null || PageOffset == null)
{
    <p>Loading browser window info...</p>
}
else
{
    <dl>
        <dt>Page Offset</dt>
        <dd>@PageOffset.X, @PageOffset.Y</dd>
        <dt>Inner Height</dt>
        <dd>@(Dimensions.InnerHeight)px</dd>
        <dt>Inner Width</dt>
        <dd>@(Dimensions.InnerWidth)px</dd>
        <dt>Outer Height</dt>
        <dd>@(Dimensions.OuterHeight)px</dd>
        <dt>Outer Width</dt>
        <dd>@(Dimensions.OuterWidth)px</dd>
    </dl>
}

@code {

    private WindowDimensions? Dimensions { get; set; }
    private PageOffset? PageOffset { get; set; }

    private void UpdateDimensions(WindowDimensions dimensions)
    {
        Dimensions = dimensions;
    }

    private void UpdatePageOffset(PageOffset pageOffset)
    {
        PageOffset = pageOffset;
    }
}

Option 2: Use Component Context

<WindowDimensionsInfo Context="dimensions" Debounce="ResizeDebounce">
    <PageOffsetInfo Context="offset" Debounce="ScrollDebounce">
        <dl>
            <dt>Page Offset</dt>
            <dd>@offset.X, @offset.Y</dd>
            <dt>Inner Height</dt>
            <dd>@(dimensions.InnerHeight)px</dd>
            <dt>Inner Width</dt>
            <dd>@(dimensions.InnerWidth)px</dd>
            <dt>Outer Height</dt>
            <dd>@(dimensions.OuterHeight)px</dd>
            <dt>Outer Width</dt>
            <dd>@(dimensions.OuterWidth)px</dd>
        </dl>
    </PageOffsetInfo>
</WindowDimensionsInfo>

Option 3: Use Cascading Values

App.razor
<CascadingWindowDimensions>
    <CascadingPageOffset>
        <Router AppAssembly="@typeof(App).Assembly">
            <Found Context="routeData">
                <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
                <FocusOnNavigate RouteData="@routeData" Selector="h1" />
            </Found>
            <NotFound>
                <PageTitle>Not found</PageTitle>
                <LayoutView Layout="@typeof(MainLayout)">
                    <p role="alert">Sorry, there's nothing at this address.</p>
                </LayoutView>
            </NotFound>
        </Router>
    </CascadingPageOffset>
</CascadingWindowDimensions>
BrowserInfo.razor
@using Tizzani.BlazorHelpers.BrowserWindow.Models

<dl>
    <dt>Page Offset</dt>
    <dd>@PageOffset.X, @PageOffset.Y</dd>
    <dt>Inner Height</dt>
    <dd>@(Dimensions.InnerHeight)px</dd>
    <dt>Inner Width</dt>
    <dd>@(Dimensions.InnerWidth)px</dd>
    <dt>Outer Height</dt>
    <dd>@(Dimensions.OuterHeight)px</dd>
    <dt>Outer Width</dt>
    <dd>@(Dimensions.OuterWidth)px</dd>
</dl>

@code {
    [CascadingValue] private WindowDimensions? Dimensions { get; set; }
    [CascadingValue] private PageOffset? PageOffset { get; set; }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 265 9/18/2022