-
Notifications
You must be signed in to change notification settings - Fork 75
docs(Window): add animation docs #2922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tsvetomir-Hr
wants to merge
1
commit into
master
Choose a base branch
from
window-animations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,125 @@ | ||||||
--- | ||||||
title: Animations | ||||||
page_title: Animations | ||||||
description: Learn about the animation options for the Telerik Window component in Blazor. | ||||||
slug: window-animations | ||||||
tags: telerik,blazor,window,animations | ||||||
published: True | ||||||
position: 4 | ||||||
--- | ||||||
|
||||||
# Blazor Window Animations | ||||||
|
||||||
The Telerik Window component for Blazor provides an option to control the opening animations to enhance the user experience. You can configure the animation type and duration using the following parameters: | ||||||
|
||||||
## Parameters | ||||||
|
||||||
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout) | ||||||
|
||||||
| Parameter | Type and Default Value | Description | | ||||||
|--------------------|------------------------------------|-------------| | ||||||
| `AnimationType` | `WindowAnimationType` (`None`) | Specifies the type of animation used when the window opens or closes. Full list of animation types is listed in the section below. | | ||||||
| `AnimationDuration`| `int` (`300`) | Defines the duration of the animation in milliseconds. | | ||||||
|
||||||
## WindowAnimation Types | ||||||
|
||||||
The `WindowAnimationType` enumeration includes the following options: | ||||||
|
||||||
* `None` (default) - No animation. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
* `SlideUp` - Slides in from the bottom and slides out to the bottom. | ||||||
* `SlideDown` - Slides in from the top and slides out to the top. | ||||||
* `SlideRight` - Slides in from the left and slides out to the left. | ||||||
* `SlideLeft` - Slides in from the right and slides out to the right. | ||||||
* `PushUp` - Pushes in from the bottom and pushes out to the top. | ||||||
* `PushDown` - Pushes in from the top and pushes out to the bottom. | ||||||
* `PushLeft` - Pushes in from the right and pushes out to the left. | ||||||
* `PushRight` - Pushes in from the left and pushes out to the right. | ||||||
* `Fade` - Fades in and out. | ||||||
* `ZoomIn` - Zooms in from a larger size to its actual size and zooms out by expanding before disappearing. | ||||||
* `ZoomOut` - Zooms in from a smaller size to its actual size and zooms out by shrinking to the center. | ||||||
|
||||||
## Example | ||||||
|
||||||
````RAZOR | ||||||
<div class="k-d-flex k-align-items-stretch k-gap-5"> | ||||||
<div class="k-d-flex k-flex-col"> | ||||||
<label for="animation">Animation Type</label> | ||||||
<TelerikDropDownList Data="@AnimationTypes" | ||||||
Value="@Animation" | ||||||
ValueChanged="@((WindowAnimationType animation) => ChangeAnimation(animation))" | ||||||
Width="130px" | ||||||
Id="animation" /> | ||||||
</div> | ||||||
|
||||||
<div class="k-d-flex k-flex-col"> | ||||||
<label for="duration">Animation Duration</label> | ||||||
<TelerikNumericTextBox @bind-Value="@Duration" | ||||||
Width="130px" | ||||||
Id="duration" /> | ||||||
</div> | ||||||
|
||||||
<div class="k-align-self-flex-end"> | ||||||
<TelerikButton OnClick="@(() => Visible = !Visible)">@(Visible ? "Hide Window" : "Show Window")</TelerikButton> | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<TelerikWindow @bind-Visible="@Visible" | ||||||
Height="300px" | ||||||
Width="300px" | ||||||
@bind-Top="@Top" | ||||||
@bind-Left="@Left" | ||||||
AnimationType="@Animation" | ||||||
AnimationDuration="@Duration"> | ||||||
<WindowTitle> | ||||||
Animations | ||||||
</WindowTitle> | ||||||
<WindowContent> | ||||||
Current animation type: <strong>@Animation</strong> | ||||||
</WindowContent> | ||||||
</TelerikWindow> | ||||||
|
||||||
@code { | ||||||
private bool Visible { get; set; } | ||||||
private int Duration { get; set; } = 300; | ||||||
private string Top { get; set; } = "50%"; | ||||||
private string Left { get; set; } = "50%"; | ||||||
|
||||||
private List<WindowAnimationType>? AnimationTypes { get; set; } | ||||||
private WindowAnimationType Animation { get; set; } = WindowAnimationType.ZoomOut; | ||||||
|
||||||
private async Task ChangeAnimation(WindowAnimationType animation) | ||||||
{ | ||||||
Animation = WindowAnimationType.None; | ||||||
Visible = false; | ||||||
// Artificial delay to reset the animation for demonstration purposes | ||||||
await Task.Delay(500); | ||||||
Animation = animation; | ||||||
Visible = true; | ||||||
} | ||||||
|
||||||
protected override async Task OnInitializedAsync() | ||||||
{ | ||||||
AnimationTypes = new List<WindowAnimationType>(); | ||||||
|
||||||
// Populate the list of animation types | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
foreach (WindowAnimationType animation in Enum.GetValues(typeof(WindowAnimationType))) | ||||||
{ | ||||||
AnimationTypes.Add(animation); | ||||||
} | ||||||
|
||||||
// Artificial delay to show the window after initialization for the sake of the example | ||||||
await Task.Delay(500); | ||||||
Visible = true; | ||||||
|
||||||
await base.OnInitializedAsync(); | ||||||
} | ||||||
} | ||||||
```` | ||||||
|
||||||
## Limitations | ||||||
|
||||||
When the Window is set to be inside a container, it may appear outside of it after the animation completes. This occurs because animation classes scale the Window component, causing it to render inside the container initially, but move outside after the transition ends. | ||||||
|
||||||
## See Also | ||||||
|
||||||
* [Blazor Window Overview](slug:window-overview) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.