Skip to content

Creating an Empty animation #15

@13r0ck

Description

@13r0ck

This is created as a discussion for PR #14 .
I thought that adding Animation.empty would make it easier to match either no animation or some animation depending on the model.

My thinking is

animatedEl
    ( if shouldAnimate then
          expandFade
      else
          Animation.empty
    )

@andrewMacmurray mentioned that he usually makes conditional animations like:

if shouldAnimate then
   Animated.div expandFade [] [ element ]
else
   element

(For understanding both use the expandFade animation from the docs.)

In my opinion both work just fine (Andrew's might be slightly more performant, but I haven't tested it, but I can't imagine it is but much ). I just like the flexibility of being able to drop in an empty animation because both "Do I want this element to animate or not" and "Do I want an animated element or not" now have direct answers.

I'm interested what others think?
Thanks!

Also I am curious, should the name be Animation.empty because that is what the code is doing, or should it be Animation.none because that is what the intent is?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions