mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
added mouse.offset
This commit is contained in:
parent
2a9d2613d6
commit
786b9af7a0
1 changed files with 11 additions and 10 deletions
|
@ -19,6 +19,7 @@ var Mouse;
|
|||
this.position = { x: 0, y: 0 };
|
||||
this.mousedownPosition = { x: 0, y: 0 };
|
||||
this.mouseupPosition = { x: 0, y: 0 };
|
||||
this.offset = { x: 0, y: 0 };
|
||||
this.button = -1;
|
||||
|
||||
this.sourceEvents = {
|
||||
|
@ -36,8 +37,8 @@ var Mouse;
|
|||
event.preventDefault();
|
||||
}
|
||||
|
||||
mouse.position.x = position.x;
|
||||
mouse.position.y = position.y;
|
||||
mouse.position.x = position.x + mouse.offset.x;
|
||||
mouse.position.y = position.y + mouse.offset.y;
|
||||
mouse.sourceEvents.mousemove = event;
|
||||
};
|
||||
|
||||
|
@ -52,10 +53,10 @@ var Mouse;
|
|||
mouse.button = event.button;
|
||||
}
|
||||
|
||||
mouse.position.x = position.x;
|
||||
mouse.position.y = position.y;
|
||||
mouse.mousedownPosition.x = position.x;
|
||||
mouse.mousedownPosition.y = position.y;
|
||||
mouse.position.x = position.x + mouse.offset.x;
|
||||
mouse.position.y = position.y + mouse.offset.y;
|
||||
mouse.mousedownPosition.x = position.x + mouse.offset.x;
|
||||
mouse.mousedownPosition.y = position.y + mouse.offset.y;
|
||||
mouse.sourceEvents.mousedown = event;
|
||||
};
|
||||
|
||||
|
@ -68,10 +69,10 @@ var Mouse;
|
|||
}
|
||||
|
||||
mouse.button = -1;
|
||||
mouse.position.x = position.x;
|
||||
mouse.position.y = position.y;
|
||||
mouse.mouseupPosition.x = position.x;
|
||||
mouse.mouseupPosition.y = position.y;
|
||||
mouse.position.x = position.x + mouse.offset.x;
|
||||
mouse.position.y = position.y + mouse.offset.y;
|
||||
mouse.mouseupPosition.x = position.x + mouse.offset.x;
|
||||
mouse.mouseupPosition.y = position.y + mouse.offset.y;
|
||||
mouse.sourceEvents.mouseup = event;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue