react-zdog
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -14,8 +14,2 @@ 'use strict'; | ||
Zdog.Anchor.prototype.renderGraphSvg = function (svg) { | ||
this.flatGraph.forEach(function (item) { | ||
return item.render(svg, Zdog.SvgRenderer); | ||
}); | ||
}; | ||
var stateContext = React__default.createContext(); | ||
@@ -97,5 +91,3 @@ var parentContext = React__default.createContext(); | ||
React.useLayoutEffect(function () { | ||
Zdog.extend(node, props); | ||
node.updateFlatGraph(); | ||
state && state.current && state.current.illu.updateGraph(); | ||
return void applyProps(node, props); | ||
}, [props]); | ||
@@ -156,7 +148,2 @@ React.useLayoutEffect(function () { | ||
React.useEffect(function () { | ||
function animate(t) { | ||
render(t); | ||
requestAnimationFrame(animate); | ||
} | ||
state.current.illu = new Zdog.Illustration(_extends({ | ||
@@ -167,2 +154,4 @@ element: canvas.current | ||
state.current.illu.updateGraph(); | ||
var frame; | ||
var active = true; | ||
@@ -186,12 +175,17 @@ function render(t) { | ||
} | ||
} | ||
animate(); | ||
if (active) frame = requestAnimationFrame(render); | ||
} // Start render loop | ||
render(); | ||
return function () { | ||
// Take no chances, the loop has got to stop if the component unmounts | ||
active = false; | ||
cancelAnimationFrame(frame); | ||
}; | ||
}, []); // Takes care of updating the main illustration | ||
React.useLayoutEffect(function () { | ||
if (state.current.illu) { | ||
Zdog.extend(state.current.illu, rest); | ||
state.current.illu.updateGraph(); | ||
} | ||
return void (state.current.illu && applyProps(state.current.illu, rest)); | ||
}, [rest]); | ||
@@ -198,0 +192,0 @@ return React__default.createElement("div", _extends({ |
@@ -7,6 +7,2 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
Zdog.Anchor.prototype.renderGraphSvg = function (svg) { | ||
this.flatGraph.forEach(item => item.render(svg, Zdog.SvgRenderer)); | ||
}; | ||
const stateContext = React.createContext(); | ||
@@ -77,8 +73,4 @@ const parentContext = React.createContext(); | ||
useImperativeHandle(ref, () => node); | ||
useLayoutEffect(() => void applyProps(node, props), [props]); | ||
useLayoutEffect(() => { | ||
Zdog.extend(node, props); | ||
node.updateFlatGraph(); | ||
state && state.current && state.current.illu.updateGraph(); | ||
}, [props]); | ||
useLayoutEffect(() => { | ||
if (parent) { | ||
@@ -133,7 +125,2 @@ parent.addChild(node); | ||
useEffect(() => { | ||
function animate(t) { | ||
render(t); | ||
requestAnimationFrame(animate); | ||
} | ||
state.current.illu = new Zdog.Illustration(_extends({ | ||
@@ -144,2 +131,4 @@ element: canvas.current | ||
state.current.illu.updateGraph(); | ||
let frame; | ||
let active = true; | ||
@@ -159,13 +148,16 @@ function render(t) { | ||
} | ||
} | ||
animate(); | ||
if (active) frame = requestAnimationFrame(render); | ||
} // Start render loop | ||
render(); | ||
return () => { | ||
// Take no chances, the loop has got to stop if the component unmounts | ||
active = false; | ||
cancelAnimationFrame(frame); | ||
}; | ||
}, []); // Takes care of updating the main illustration | ||
useLayoutEffect(() => { | ||
if (state.current.illu) { | ||
Zdog.extend(state.current.illu, rest); | ||
state.current.illu.updateGraph(); | ||
} | ||
}, [rest]); | ||
useLayoutEffect(() => void (state.current.illu && applyProps(state.current.illu, rest)), [rest]); | ||
return React.createElement("div", _extends({ | ||
@@ -172,0 +164,0 @@ ref: bind.ref |
36
index.js
@@ -5,7 +5,2 @@ import Zdog from 'zdog' | ||
// Temporary hack: https://github.com/metafizzy/zdog/issues/44 | ||
Zdog.Anchor.prototype.renderGraphSvg = function(svg) { | ||
this.flatGraph.forEach(item => item.render(svg, Zdog.SvgRenderer)) | ||
} | ||
const stateContext = React.createContext() | ||
@@ -25,2 +20,3 @@ const parentContext = React.createContext() | ||
Zdog.extend(instance, newProps) | ||
invalidate() | ||
} | ||
@@ -59,8 +55,4 @@ | ||
useImperativeHandle(ref, () => node) | ||
useLayoutEffect(() => void applyProps(node, props), [props]) | ||
useLayoutEffect(() => { | ||
Zdog.extend(node, props) | ||
node.updateFlatGraph() | ||
state && state.current && state.current.illu.updateGraph() | ||
}, [props]) | ||
useLayoutEffect(() => { | ||
if (parent) { | ||
@@ -101,7 +93,2 @@ parent.addChild(node) | ||
useEffect(() => { | ||
function animate(t) { | ||
render(t) | ||
requestAnimationFrame(animate) | ||
} | ||
state.current.illu = new Zdog.Illustration({ element: canvas.current, ...rest }) | ||
@@ -111,2 +98,4 @@ state.current.illu.addChild(scene) | ||
let frame | ||
let active = true | ||
function render(t) { | ||
@@ -122,14 +111,17 @@ const { size, subscribers } = state.current | ||
} | ||
if (active) frame = requestAnimationFrame(render) | ||
} | ||
animate() | ||
// Start render loop | ||
render() | ||
return () => { | ||
// Take no chances, the loop has got to stop if the component unmounts | ||
active = false | ||
cancelAnimationFrame(frame) | ||
} | ||
}, []) | ||
// Takes care of updating the main illustration | ||
useLayoutEffect(() => { | ||
if (state.current.illu) { | ||
Zdog.extend(state.current.illu, rest) | ||
state.current.illu.updateGraph() | ||
} | ||
}, [rest]) | ||
useLayoutEffect(() => void (state.current.illu && applyProps(state.current.illu, rest)), [rest]) | ||
@@ -136,0 +128,0 @@ return ( |
{ | ||
"name": "react-zdog", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "React-fiber renderer for zdog", | ||
@@ -54,5 +54,6 @@ "main": "dist/index.cjs.js", | ||
"react-dom": ">=16.8", | ||
"zdog": ">=1.2" | ||
"zdog": ">=1.1" | ||
}, | ||
"devDependencies": { | ||
"zdog": "^1.1.0", | ||
"@babel/core": "7.4.4", | ||
@@ -82,5 +83,4 @@ "@babel/plugin-proposal-class-properties": "7.4.4", | ||
"rollup-plugin-node-resolve": "^4.2.3", | ||
"rollup-plugin-size-snapshot": "^0.8.0", | ||
"zdog": "^1.0.2" | ||
"rollup-plugin-size-snapshot": "^0.8.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24685
601