Skip to content

Commit 10ec860

Browse files
authored
Update index.ts
1 parent ecbecd6 commit 10ec860

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/targets/zdog/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useTransition } from '../../useTransition'
1313
import { merge } from '../../shared/helpers'
1414
import { 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
1717
const {
1818
invalidate,
1919
applyProps,
@@ -30,19 +30,22 @@ for (let key of Object.keys(elements)) {
3030
}
3131

3232
if (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
4042
Globals.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
4244
Globals.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"
4446
Globals.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
4649
Globals.injectApplyAnimatedValues(applyProps, style => style)
4750

4851
export {

0 commit comments

Comments
 (0)