metafizzy / zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
https://zzz.dog
10.37k stars 394 forks source link

React support (i would do it) #28

Open drcmda opened 5 years ago

drcmda commented 5 years ago

If you like i could support it: https://github.com/drcmda/react-zdog

either by making a reconciler (with native elements for rect/ellipse/etc) or wraps - not sure yet. But zdog seems a little rough atm and i am encountering lots of bugs. Would it be ok to discuss this here?

This is how it looks atm:

Demo: https://codesandbox.io/s/nervous-feather-vk9uh

Of course that would allow you to create reactive components, and open it up to the react eco system. You would be able to transition these objects, use routes, animate them (react-spring, etc).

drcmda commented 5 years ago

The troubles i run into:

And some concerns regarding the overall direction

lostfictions commented 5 years ago

Seconding this! I would love React support specifically, but more generally I think it would be great if zdog were a little friendlier in terms of interoperability and placing nice with other code and libraries.

boardfish commented 5 years ago

Yes please! I'm trying to do this with refs at the minute as recommended in another issue, but I'd far prefer a React interface to the library.

drcmda commented 5 years ago

I've gotten pretty far, mount/unmount is fixed, so everything is reactive, all primitives are supported. I've updated the demo above: https://codesandbox.io/s/nervous-feather-vk9uh

Since the esm npm exports are still broken i added a rule to rollup to transpile zdog into the distro, so react-npm is available now...

Neon22 commented 5 years ago

Ahh - could you support Vue as well ? Please...

drcmda commented 5 years ago

You could copy the code and convert the few parts that don't fit. I use a generic approach, so that i don't have to chase behind implementation specifics.

boardfish commented 5 years ago

@desandro and any other Metafizzy folk, please do take a look at react-zdog - I really appreciate the effort @drcmda has gone to in order to bring it inline with standard Zdog functionality. drcmda.props for a job well done!

flyskywhy commented 3 years ago

Plus, react-native support here 😋

No need modify any code of framework zdog itself.

Only modify one line code of app demo Made with Zdog CodePen Collection, e.g. just modify .zdog-canvas in JS of https://codepen.io/clarke-nicol/pen/OezRdM into this.canvas in zdog() of demo/zdog-and-tests.js.

Here is the result of demo/zdog-and-tests.js, you can directly discover that the render and mousemove is same with the original html version https://codepen.io/clarke-nicol/pen/OezRdM.