0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-25 13:39:06 -05:00

added Mouse.create warning for omitted element

This commit is contained in:
liabru 2015-01-21 00:10:10 +00:00
parent c220f41701
commit af83e27ff0

View file

@ -16,6 +16,10 @@ var Mouse = {};
*/
Mouse.create = function(element) {
var mouse = {};
if (!element) {
Common.log('Mouse.create: element was undefined, defaulting to document.body', 'warn');
}
mouse.element = element || document.body;
mouse.absolute = { x: 0, y: 0 };
@ -26,7 +30,7 @@ var Mouse = {};
mouse.scale = { x: 1, y: 1 };
mouse.wheelDelta = 0;
mouse.button = -1;
mouse.pixelRatio = element.getAttribute('data-pixel-ratio') || 1;
mouse.pixelRatio = mouse.element.getAttribute('data-pixel-ratio') || 1;
mouse.sourceEvents = {
mousemove: null,