Skip to content

Commit

Permalink
added MouseConstraint.create warning for omitted element
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jan 21, 2015
1 parent af83e27 commit b6603ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/constraint/MouseConstraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ var MouseConstraint = {};
* @return {MouseConstraint} A new MouseConstraint
*/
MouseConstraint.create = function(engine, options) {
var mouse = (options && options.mouse) || Mouse.create(engine.render.canvas);
var mouse = (engine ? engine.mouse : null) || (options ? options.mouse : null);

if (!mouse && engine && engine.render && engine.render.canvas) {
mouse = Mouse.create(engine.render.canvas);
} else {
mouse = Mouse.create();
Common.log('MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected', 'warn');
}

var constraint = Constraint.create({
label: 'Mouse Constraint',
Expand Down

0 comments on commit b6603ca

Please sign in to comment.