This commit is contained in:
James Clancey 2022-05-02 10:53:24 -08:00
Родитель 99b87a4ca2
Коммит 3ee062c5e0
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -7,7 +7,11 @@ namespace Comet
{
public static class AnimationExtensions
{
public static FrameConstraints Lerp(this FrameConstraints start, FrameConstraints end, double progress)
=> new FrameConstraints(
start.Width.Lerp(end.Width, progress),
start.Height.Lerp(end.Height, progress)
);
public static T Animate<T>(this T view, Action<T> action, Action completed = null, double duration = .2, double delay = 0, bool repeats = false, bool autoReverses = false, string id = null, Lerp lerp = null)
where T : View => view.Animate(Easing.Default, action, completed, duration, delay, repeats, autoReverses, id, lerp);

Просмотреть файл

@ -4,6 +4,7 @@ using Comet.Handlers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Maui;
using Microsoft.Maui.Animations;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Devices;
using Microsoft.Maui.Handlers;
@ -37,6 +38,14 @@ namespace Comet
ViewHandler.ViewMapper.AppendToMapping(nameof(IGestureView.Gestures), CometViewHandler.AddGestures);
ViewHandler.ViewCommandMapper.AppendToMapping(Gesture.AddGestureProperty, CometViewHandler.AddGesture);
ViewHandler.ViewCommandMapper.AppendToMapping(Gesture.AddGestureProperty, CometViewHandler.RemoveGesture);
Lerp.Lerps[typeof(FrameConstraints)] = new Lerp
{
Calculate = (s, e, progress) => {
var start = (FrameConstraints)s;
var end = (FrameConstraints)(e);
return start.Lerp(end, progress);
}
};
builder.ConfigureMauiHandlers((handlersCollection) => handlersCollection.AddHandlers(new Dictionary<Type, Type>
{
{ typeof(AbstractLayout), typeof(LayoutHandler) },