Skip to content

Commit

Permalink
updated edge build
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 2, 2014
1 parent 7c75614 commit 02ab198
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
58 changes: 38 additions & 20 deletions build/matter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* matter.js 0.8.0-edge 2014-07-30
* matter.js 0.8.0-edge 2014-12-02
* http://brm.io/matter-js/
* License: MIT
*/
Expand Down Expand Up @@ -3440,8 +3440,7 @@ var MouseConstraint = {};
var defaults = {
type: 'mouseConstraint',
mouse: mouse,
dragBody: null,
dragPoint: null,
body: null,
constraint: constraint,
collisionFilter: {
category: 0x0001,
Expand Down Expand Up @@ -3470,31 +3469,36 @@ var MouseConstraint = {};
*/
MouseConstraint.update = function(mouseConstraint, bodies) {
var mouse = mouseConstraint.mouse,
constraint = mouseConstraint.constraint;
constraint = mouseConstraint.constraint,
body = mouseConstraint.body;

if (mouse.button === 0) {
if (!constraint.bodyB) {
for (var i = 0; i < bodies.length; i++) {
var body = bodies[i];
body = bodies[i];
if (Bounds.contains(body.bounds, mouse.position)
&& Vertices.contains(body.vertices, mouse.position)
&& Detector.canCollide(body.collisionFilter, mouseConstraint.collisionFilter)) {

constraint.pointA = mouse.position;
constraint.bodyB = body;
constraint.bodyB = mouseConstraint.body = body;
constraint.pointB = { x: mouse.position.x - body.position.x, y: mouse.position.y - body.position.y };
constraint.angleB = body.angle;

Sleeping.set(body, false);
Events.trigger(mouseConstraint, 'startdrag', { mouse: mouse, body: body });
}
}
} else {
Sleeping.set(constraint.bodyB, false);
constraint.pointA = mouse.position;
}
} else {
constraint.bodyB = null;
constraint.bodyB = mouseConstraint.body = null;
constraint.pointB = null;
}

if (constraint.bodyB) {
Sleeping.set(constraint.bodyB, false);
constraint.pointA = mouse.position;
if (body)
Events.trigger(mouseConstraint, 'enddrag', { mouse: mouse, body: body });
}
};

Expand Down Expand Up @@ -3557,6 +3561,28 @@ var MouseConstraint = {};
* @param {} event.name The name of the event
*/

/**
* Fired when the user starts dragging a body
*
* @event startdrag
* @param {} event An event object
* @param {mouse} event.mouse The engine's mouse instance
* @param {body} event.body The body being dragged
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/

/**
* Fired when the user ends dragging a body
*
* @event enddrag
* @param {} event An event object
* @param {mouse} event.mouse The engine's mouse instance
* @param {body} event.body The body that has stopped being dragged
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/

/*
*
* Properties Documentation
Expand All @@ -3582,15 +3608,7 @@ var MouseConstraint = {};
/**
* The `Body` that is currently being moved by the user, or `null` if no body.
*
* @property dragBody
* @type body
* @default null
*/

/**
* The `Vector` offset at which the drag started relative to the `dragBody`, if any.
*
* @property dragPoint
* @property body
* @type body
* @default null
*/
Expand Down
Loading

0 comments on commit 02ab198

Please sign in to comment.