@@ -13,7 +13,7 @@ import { useTransition } from '../../useTransition'
1313import { merge } from '../../shared/helpers'
1414import { update } from '../../animated/FrameLoop'
1515
16- // Extend animated with all the available ZDOG elements
16+ // Extend animated with all the available ZDOG elements, so that we can do animated.Shape/Ellipse/.. later on
1717const {
1818 invalidate,
1919 applyProps,
@@ -30,19 +30,22 @@ for (let key of Object.keys(elements)) {
3030}
3131
3232if ( addEffect ) {
33- // Add the update function as a global effect to react-zdog's update loop
33+ // Add react-springs update function as a global effect to react-zdog's render loop
34+ // Having multiple requestAnimationFrame-loops is very bad for performance, so we join them
3435 addEffect ( update )
35- // Ping react-three-fiber, so that it will call react-springs update function as an effect
36+ // This one switches off react-springs own render loop, instead it will call us back whenever
37+ // it needs to render, we use this to invalidate react-zdog's render loop, in case it renders on demand
3638 Globals . injectManualFrameloop ( ( ) => invalidate ( ) )
3739}
3840
3941// Set default native-element
4042Globals . injectDefaultElement ( Zdog . Anchor )
41- // Use default interpolation (which includes numbers, strings, colors)
43+ // Use default interpolation (which includes numbers, strings, colors), zdog uses web standards
4244Globals . injectStringInterpolator ( createInterpolation )
43- // Inject color names, so that it will be able to deal with things like "peachpuff"
45+ // Inject web color names, so that it will be able to deal with things like "peachpuff"
4446Globals . injectColorNames ( colorNames )
4547// This is how we teach react-spring to set props "natively", the api is (instance, props) => { ... }
48+ // It will write updates directly into the view from now on, avoiding component updates through React
4649Globals . injectApplyAnimatedValues ( applyProps , style => style )
4750
4851export {
0 commit comments