Skip to content

Fix Issue with call from Timer #3

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions SAPBlazorAnimate/SAPAnimate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
Animator = animatebookType;
await Task.Delay(1000);
Animator = "";
StateHasChanged();
await InvokeAsync(StateHasChanged);
}
/// <summary>
/// set delay for removing on animation
/// </summary>
/// <param name="animatebookType"></param>
/// <param name="delay"></param>
public async void Animate(string animatebookType, TimeSpan delay )
public async void Animate(string animatebookType, TimeSpan delay )
{
Animator = animatebookType;
await Task.Delay(delay);
Animator = "";
StateHasChanged();
await InvokeAsync(StateHasChanged);
}

}
6 changes: 3 additions & 3 deletions SAPBlazorAnimate/SAPBlazorAnimate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<PackageIcon>blazorlogo.png</PackageIcon>
<PackageIconUrl />
<PackageReleaseNotes>added fast , faster , slow , slower animation modes</PackageReleaseNotes>
<AssemblyVersion>1.2.6.0</AssemblyVersion>
<FileVersion>1.2.6.0</FileVersion>
<Version>1.2.6</Version>
<AssemblyVersion>1.2.6.1</AssemblyVersion>
<FileVersion>1.2.6.1</FileVersion>
<Version>1.2.6.1</Version>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseFile>License.md</PackageLicenseFile>
</PropertyGroup>
Expand Down
59 changes: 53 additions & 6 deletions SAPBlazorAnimateDemo/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/"
@using System.Timers;
@page "/"

<h1 class="@AnimateBook.Lightspeed.LightSpeedIn.Faster()">Hello, world!</h1>

Expand Down Expand Up @@ -67,6 +68,8 @@

@code
{
private Timer _timer;
private int _counter = 0;

SAPAnimate animatedElement1;
SAPAnimate animatedElement2;
Expand All @@ -75,28 +78,72 @@
SAPAnimate animatedElement5;
SAPAnimate animatedElement6;

protected override async Task OnInitializedAsync()
{

_timer = new Timer(5000);



_timer.Elapsed += (sender, e) =>
{
_counter++;
switch (_counter)
{
case 1:
animatedElement1.Animate(AnimateBook.AttentionSeekers.HeartBeat);
break;
case 2:
animatedElement2.Animate(AnimateBook.AttentionSeekers.HeartBeat);
break;
case 3:
animatedElement3.Animate(AnimateBook.AttentionSeekers.HeartBeat);
break;
case 4:
animatedElement4.Animate(AnimateBook.AttentionSeekers.HeartBeat);
break;
case 5:
animatedElement5.Animate(AnimateBook.AttentionSeekers.HeartBeat);
break;
case 6:
animatedElement6.Animate(AnimateBook.AttentionSeekers.HeartBeat);
_counter = 0;
break;
default:
_counter = 0;
break;
}


InvokeAsync(StateHasChanged);
};

_timer.Start();

await base.OnInitializedAsync();
}

void btn1Click()
{
animatedElement1.Animate(AnimateBook.AttentionSeekers.HeartBeat);
}
void btn2Click()
void btn2Click()
{
animatedElement2.Animate(AnimateBook.Flippers.FlipInX);
}
void btn3Click()
void btn3Click()
{
animatedElement3.Animate(AnimateBook.SlidingExits.SlideOutUp);
}
void btn4Click()
void btn4Click()
{
animatedElement4.Animate(AnimateBook.ZoomEntrances.ZoomIn);
}
void btn5Click()
void btn5Click()
{
animatedElement5.Animate(AnimateBook.ZoomEntrances.ZoomIn.Slower());
}
void btn6Click()
void btn6Click()
{
animatedElement6.Animate(AnimateBook.ZoomEntrances.ZoomIn.Faster());
}
Expand Down