Skip to content

Better ways to add repeated animations #28

@kkjamie

Description

@kkjamie

Problem

Quite often you want a sequence that contains a repeated portion of an animation.
There is no decent way to do this, you either loop and create multiple instance of identical animations, or create one and add it multiple times. You can use linq, but then the .Add function only accepts params array, so requires a cast to an array,

Proposals

  1. A new overload AnimationCollection.Add(IEnumerable<TAnimation> animations) where TAnimation : AbstractAnimation
    This would allow us to use linq. so we can do don't need to do ToArray. the type parameters are present so we don't need .Cast<AbsrtactAnimation> - to surpress covariance warnings.

  2. Modify the original Add(params AbstractAnimation[] animations) to use type params for the same reason as above.

  3. A new overload Add(AbstractAnimation animation, int amount) so we can easily reuse the same instance multiple times over just using an integer

  4. ForEach(IEnumerable<T>, Func<T, AbstractAnimation> createAnimation) so we can map elements in an array to a corresponding animation
    eg: given a list of transforms myTransforms
    sequence.ForEach(myTransforms, t => t.Move(from, to, duration, easing));

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions