Skip to content

Commit

Permalink
added Mouse.create warning for omitted element
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jan 21, 2015
1 parent c220f41 commit af83e27
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/Mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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,
Expand Down

0 comments on commit af83e27

Please sign in to comment.