0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added beforeRender and afterRender events to Matter.Render

This commit is contained in:
liabru 2015-07-29 20:26:35 +01:00
parent dcdc43d475
commit aa48322329

View file

@ -127,6 +127,12 @@ var Render = {};
constraints = [], constraints = [],
i; i;
var event = {
timestamp: engine.timing.timestamp
};
Events.trigger(render, 'beforeRender', event);
// apply background if it has changed // apply background if it has changed
if (render.currentBackground !== background) if (render.currentBackground !== background)
_applyBackground(render, background); _applyBackground(render, background);
@ -224,6 +230,8 @@ var Render = {};
// revert view transforms // revert view transforms
context.setTransform(options.pixelRatio, 0, 0, options.pixelRatio, 0, 0); context.setTransform(options.pixelRatio, 0, 0, options.pixelRatio, 0, 0);
} }
Events.trigger(render, 'afterRender', event);
}; };
/** /**
@ -1118,6 +1126,32 @@ var Render = {};
render.currentBackground = background; 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 * Properties Documentation