From 73fd49c58a3323459ab743dc93e4882eaecdb026 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 28 Feb 2018 16:33:23 -0800 Subject: [PATCH] Added onRender callback for after each frame --- springy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/springy.js b/springy.js index c93c399..b96a2f1 100644 --- a/springy.js +++ b/springy.js @@ -645,14 +645,16 @@ * Renderer handles the layout rendering loop * @param onRenderStop optional callback function that gets executed whenever rendering stops. * @param onRenderStart optional callback function that gets executed whenever rendering starts. + * @param onRender optional callback function that gets executed after each frame is rendered. */ - var Renderer = Springy.Renderer = function(layout, clear, drawEdge, drawNode, onRenderStop, onRenderStart) { + var Renderer = Springy.Renderer = function(layout, clear, drawEdge, drawNode, onRenderStop, onRenderStart, onRender) { this.layout = layout; this.clear = clear; this.drawEdge = drawEdge; this.drawNode = drawNode; this.onRenderStop = onRenderStop; this.onRenderStart = onRenderStart; + this.onRender = onRender; this.layout.graph.addGraphListener(this); } @@ -683,6 +685,8 @@ t.layout.eachNode(function(node, point) { t.drawNode(node, point.p); }); + + if (t.onRender !== undefined) { t.onRender(); } }, this.onRenderStop, this.onRenderStart); };