From af83e27ff073a846da6af42390005766b552c632 Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 21 Jan 2015 00:10:10 +0000 Subject: [PATCH] added Mouse.create warning for omitted element --- src/core/Mouse.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/Mouse.js b/src/core/Mouse.js index 40e1407..b8b8da6 100644 --- a/src/core/Mouse.js +++ b/src/core/Mouse.js @@ -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,