react-web-animation icon indicating copy to clipboard operation
react-web-animation copied to clipboard

Idea: Allow <Animatable> at any depth

Open nevir opened this issue 8 years ago • 3 comments

It would be handy to support <Animatable> elements at any depth under a <AnimationGroup> or <AnimationSequence>. I.e.

<AnimationGroup ...>
  <Animatable ...>
    <div>
      ohai
      <Animatable ...>
        <div>ohai2u</div>
      </Animatable>
    </div>
  </Animatable>

I'm unsure what all the implications would be though. Would crawling the element tree on render going to be too much of a perf burden? Similarly, someone might be tempted to nesting <Animatable>s inside other <Animatable> - though, that should be ok, I think :P

nevir avatar Apr 19 '16 04:04 nevir

@nevir this is a great idea, I haven't gotten around to tackling it however. That was the main idea around the Animatable interface. If you read the Web Animations API interface for a AnimationGroup, it essentially maintains one player for a bunch of keyframes + timing combinations. The tree depth shouldn't matter. The steps would be something like -

  • Search Children for Animatable ( I think there are Children traversing tools out there..)
  • Clone each element to get access to the ref.
  • Create data structure to store nested Refs+ props
  • Flatten into flat array of KeyframeEffect

To make things even more interesting, the spec fully supports nesting AnimationGroup and AnimationSequences in any nesting order.. e.g. Grouped Sequences or Sequenced Groups. So I want to tackle that at some point as well..

bringking avatar Apr 19 '16 04:04 bringking

Yeah, no worries - and thanks for building this project out; it's already been tremendously helpful :)

nevir avatar Apr 19 '16 04:04 nevir

+1 for this feature.

Tharon-C avatar Jul 09 '16 17:07 Tharon-C