Skip to content

Commit

Permalink
added beforeRender and afterRender events to Matter.Render
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 29, 2015
1 parent dcdc43d commit aa48322
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -224,6 +230,8 @@ var Render = {};
// revert view transforms
context.setTransform(options.pixelRatio, 0, 0, options.pixelRatio, 0, 0);
}

Events.trigger(render, 'afterRender', event);
};

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aa48322

Please sign in to comment.