Skip to content

Commit

Permalink
fixed issue with MouseConstraint.create, closes #185
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 23, 2015
1 parent 37a86cd commit dff0e30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions build/matter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3763,11 +3763,13 @@ var Bounds = require('../geometry/Bounds');
MouseConstraint.create = function(engine, options) {
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');
if (!mouse) {
if (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({
Expand Down
4 changes: 2 additions & 2 deletions build/matter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/constraint/MouseConstraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ var Bounds = require('../geometry/Bounds');
MouseConstraint.create = function(engine, options) {
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');
if (!mouse) {
if (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({
Expand Down

0 comments on commit dff0e30

Please sign in to comment.