I am simply trying to toggle an Animation Container and have it ZoomOut when it opens, but ZoomIn when it closes. Thought I could update the AnimationType using the reference, but does not work. Please see attached.
3 Answers, 1 is accepted
0
Accepted
Marin Bratanov
Telerik team
answered on 11 Mar 2021, 12:02 PM
Hello Rob,
You should set the parameters, not the instance properties - setting parameters lets the component react and re-render.
The key thing is that you need to give the framework a bit of time to re-render with the new settings so that they can take affect, and a small Task.Delay() is the usual way to do that:
<div style="position:relative; border: 1px solid red; height: 300px;">
<TelerikButton OnClick="@ToggleContainer" >Toggle Animation Container</TelerikButton>
<TelerikAnimationContainer @ref="myPopupRef" Top="50px" Left="50px" Width="250px" Height="150px"AnimationType="@DesiredAnmation"Class="k-popup" >
<p>
The "k-popup"classaddssomebackgroundandborderswhichyoucandefinethroughyourownstylesinstead.
</p>
<p>
Myparentelementhas <code>position: relative</code> tocontrolmy <code>Top</code> and <code>Left</code> offset.
</p>
</TelerikAnimationContainer>
</div>
@code {
Telerik.Blazor.Components.TelerikAnimationContainer myPopupRef;
bool toggledOpen = false;
AnimationType DesiredAnmation => toggledOpen ? AnimationType.ZoomIn : AnimationType.ZoomOut;async Task ToggleContainer()
{
toggledOpen = !toggledOpen;
await Task.Delay(30);// give the framework time to re-render with the new settingsawait myPopupRef.ToggleAsync();
}
}
On another note, would you mind if I moved this thread to the public forums so other people can see this scenario and benefit from it?
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.