Xamarin Forms has a great code sample for an expanding circle. It looks like this:
I'm now trying to make it so the effect stops but continues drawing the final circles before disappearing completely. A sort of ripple effect, like a stone dropped in a pool.
I've read through the code. I understand that the for loop draws 5 circles over and over. I also understand that the timer is used to repeat the drawing pattern. But animation isn't really my strong suit, so I'm not sure how I can suddenly stop all new draws. My impression is that this might take quite a big refactor given the 2 parts I've just described.
I somehow need a boolean that when set to false, causes the last few animations to finish and then stop drawing any new circles.
Using the sample code's touch effects implementation, I am able to stop the animation after a 2 second period. I do this like so:
void OnTouchEffectAction(object sender, TouchActionEventArgs args)
{
switch (args.Type)
{
case TouchActionType.Pressed:
tappedPoint = ConvertToPixel(args.Location);
stopwatch.Start();
Device.StartTimer(TimeSpan.FromMilliseconds(2000), () =>
{
pageIsActive = false;
return pageIsActive;
});
break;
}
}
So after two seconds, the animation stops. But this leaves the circles stuck in place, and I have no idea how to make them continue to ripple like they have been in the loop.
Does anyone know how I might go about this?