From aa4832232901e3bd6e57b10ff3611dcc74b66f0f Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 29 Jul 2015 20:26:35 +0100 Subject: [PATCH] added beforeRender and afterRender events to Matter.Render --- src/render/Render.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/render/Render.js b/src/render/Render.js index 30440a59..9c7fea70 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -127,6 +127,12 @@ var Render = {}; constraints = [], i; + var event = { + timestamp: engine.timing.timestamp + }; + + Events.trigger(render, 'beforeRender', event); + // apply background if it has changed if (render.currentBackground !== background) _applyBackground(render, background); @@ -224,6 +230,8 @@ var Render = {}; // revert view transforms context.setTransform(options.pixelRatio, 0, 0, options.pixelRatio, 0, 0); } + + Events.trigger(render, 'afterRender', event); }; /** @@ -1118,6 +1126,32 @@ var Render = {}; render.currentBackground = background; }; + /* + * + * Events Documentation + * + */ + + /** + * Fired before rendering + * + * @event beforeRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after rendering + * + * @event afterRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + /* * * Properties Documentation