Skip to content Skip to sidebar Skip to footer

How To Make A Method Chain Conditional?

I'm using an animation library called anime.js. I need to make conditional an animation of the chain (timeline) basing on some check. For example, this is my timeline: const tl = a

Solution 1:

Do it without chaining, using an if statement:

const tl = anime.timeline();

if (a) {
    tl.add(animation_1); 
}

t1.add(animation_2)
  .add(animation_3);

Post a Comment for "How To Make A Method Chain Conditional?"