Olical / react-faux-dom

DOM like structure that renders to React (unmaintained, archived)
http://oli.me.uk/2015/09/09/d3-within-react-the-right-way/
The Unlicense
1.21k stars 87 forks source link

Create deterministic animateFauxDOM #122

Closed TheBurnDoc closed 6 years ago

TheBurnDoc commented 6 years ago

Hi,

Love the lib btw, with the one exception that I don't really like the race between D3 and FauxDOM that occurs when you call animateFauxDOM. When an transition lasts 1000 ms and you have to call the function with an arbitrary duration and hope if finishes just feels horrible to me.

With this in mind I thought up a scheme that we could write a second, deterministic, animateFauxDOM that uses D3 transition.on("start") and transition.on("end") hooks to update a boolean state variable this.state.animating or something. Then call an asynchronous function that loops until the variable is false this ensuring the DOM is updated through the duration of the animation, no shorted, no longer.

My Javascript is still pretty amaturish, and I would like to add this myself as a PR, but want to check with you first to see if you think this scheme will even work?

Olical commented 6 years ago

This would be good, I didn't have a hand in the animation code and I didn't implement it in the first place since I wasn't sure how to do it. Anything that involves a state being coordinated could get pretty easily broken if a hook isn't called due to an exception or if someone starts two animations at once.

I haven't used the current animation style, but if there's a simpler, deterministic solution, I'm all ears :smile: maybe try messing with it on a fork and see what you get? No harm done if not, if you get something you think is on the right track I can take a look and discuss it further, no pressure though!

I'm mainly just doing small maintenance tasks for this project at the moment, so I'm not thinking in terms of large changes.

Olical commented 6 years ago

So I'm not going to do anything about this right now, but I'm going to leave it open because it's a good idea and should probably happen at some point. It's just outside of my (personal) scope right now. If anyone wants to overhaul how animations are supported, be my guest :smiley:

graingert commented 6 years ago

If anyone wants to overhaul how animations are supported

I think the best way would be to use Proxy to notify when Elements or style is edited, then buffer those changes until next frame.

Olical commented 6 years ago

Going to close this for now I'm afraid, just not something I have the time or motivation for just right now. If anyone would like to work on this feature I'll be more than happy to talk about it though!