mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
added Mouse.create warning for omitted element
This commit is contained in:
parent
c220f41701
commit
af83e27ff0
1 changed files with 5 additions and 1 deletions
|
@ -16,6 +16,10 @@ var Mouse = {};
|
||||||
*/
|
*/
|
||||||
Mouse.create = function(element) {
|
Mouse.create = function(element) {
|
||||||
var mouse = {};
|
var mouse = {};
|
||||||
|
|
||||||
|
if (!element) {
|
||||||
|
Common.log('Mouse.create: element was undefined, defaulting to document.body', 'warn');
|
||||||
|
}
|
||||||
|
|
||||||
mouse.element = element || document.body;
|
mouse.element = element || document.body;
|
||||||
mouse.absolute = { x: 0, y: 0 };
|
mouse.absolute = { x: 0, y: 0 };
|
||||||
|
@ -26,7 +30,7 @@ var Mouse = {};
|
||||||
mouse.scale = { x: 1, y: 1 };
|
mouse.scale = { x: 1, y: 1 };
|
||||||
mouse.wheelDelta = 0;
|
mouse.wheelDelta = 0;
|
||||||
mouse.button = -1;
|
mouse.button = -1;
|
||||||
mouse.pixelRatio = element.getAttribute('data-pixel-ratio') || 1;
|
mouse.pixelRatio = mouse.element.getAttribute('data-pixel-ratio') || 1;
|
||||||
|
|
||||||
mouse.sourceEvents = {
|
mouse.sourceEvents = {
|
||||||
mousemove: null,
|
mousemove: null,
|
||||||
|
|
Loading…
Reference in a new issue