ScreenOrientation
How to use the ScreenOrientation class of the bit Butil?
Usage
To use the browser ScreenOrientation features you need to inject the Bit.Butil.ScreenOrientation class and use it like this:
@inject Bit.Butil.ScreenOrientation screenOrientation
@code {
var angle = await screenOrientation.GetAngle();
}Methods
GetOrientationType:
Returns the document's current orientation type. (MDN).
@inject Bit.Butil.ScreenOrientation screenOrientation
<BitButton OnClick="@GetOrientationType">GetOrientationType</BitButton>
<div>Orientation type: @orientationType</div>
@code {
private string? orientationType;
private async Task GetOrientationType()
{
var result = await screenOrientation.GetOrientationType();
orientationType = result.ToString();
}
}GetAngle:
Returns the document's current orientation angle. (MDN).
@inject Bit.Butil.ScreenOrientation screenOrientation
<BitButton OnClick="@GetAngle">GetAngle</BitButton>
<div>Angle: @angle</div>
@code {
private ushort angle;
private async Task GetAngle()
{
angle = await screenOrientation.GetAngle();
}
}Lock:
Locks the orientation of the containing document to the specified orientation. Typically orientation locking is only enabled on mobile devices, and when the browser context is full screen. (MDN).
Unlock:
Unlocks the orientation of the containing document from its default orientation. (MDN).
AddChange, RemoveChange:
The change event of the ScreenOrientation interface fires when the orientation of the screen has changed, for example when a user rotates their mobile phone. (MDN).