@page "/"
<button class="btn btn-primary" @onclick="tt">Ver caer</button>
<div>
<svg viewBox="0 0 100 100">
<circle cx="10" cy="8" r="5" fill="blue" stroke="black" stroke-width="0.2" transform="translate(10,@c1)">
</circle>
<rect x="10" y="25" width="4" height="4" fill="red" stroke="black" stroke-width="0.5">
</rect>
</svg>
</div>
@code {
int c1 = 8;
private static System.Timers.Timer aTimer;
void tt()
{
if (aTimer is null)
{
aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += (sender,args) => { c1 = c1 > 16 ? 8 : c1+1; InvokeAsync(StateHasChanged); };
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
else
{
aTimer.Stop();
aTimer.Dispose();
aTimer = null;
}
}
}