Do we need to add states to create simple animations such as ScaleTo, FadeTo, etc on tap?
Use a component, with a layout control containing the Children element and animate it when tapped:
class AnimatedComponent: Component
{
private Func<Task>? _action;
private MauiControls.Grid? _containerGrid;
public AnimatedComponent OnTapped(Func<Task> action)
{
_action = action;
return this;
}
public override VisualNode Render()
{
return new Grid(grid => _containerGrid = grid)
{
Children()
}
.OnTapped(async () =>
{
if (_containerGrid != null && _action != null)
{
await MauiControls.ViewExtensions.ScaleTo(_containerGrid, 0.7);
await _action.Invoke();
await MauiControls.ViewExtensions.ScaleTo(_containerGrid, 1.0);
}
});
}
}Create an extension function for the MauiReactor widget that realizes the animation:
Create a component that renders just one child animated when tapped:

PreviousDoes this support ObservableCollection for CollectionView?NextHow to deal with custom dialogs/popups?
Last updated