mirror of
https://github.com/liabru/matter-js.git
synced 2025-02-07 19:06:26 -05:00
fix Mouse inaccuracy when pixelRatio is not int
This commit is contained in:
parent
e909b0466c
commit
968b8b5735
1 changed files with 8 additions and 4 deletions
|
@ -34,7 +34,7 @@ var Common = require('../core/Common');
|
||||||
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 = parseInt(mouse.element.getAttribute('data-pixel-ratio'), 10) || 1;
|
mouse.pixelRatio = mouse.element.getAttribute('data-pixel-ratio') || 1;
|
||||||
|
|
||||||
mouse.sourceEvents = {
|
mouse.sourceEvents = {
|
||||||
mousemove: null,
|
mousemove: null,
|
||||||
|
@ -192,9 +192,13 @@ var Common = require('../core/Common');
|
||||||
y = event.pageY - elementBounds.top - scrollY;
|
y = event.pageY - elementBounds.top - scrollY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: x / (element.clientWidth / (element.width || element.clientWidth) * pixelRatio),
|
x: parseInt(
|
||||||
y: y / (element.clientHeight / (element.height || element.clientHeight) * pixelRatio)
|
x / (element.clientWidth / (element.width || element.clientWidth) * pixelRatio)
|
||||||
|
, 10),
|
||||||
|
y: parseInt(
|
||||||
|
y / (element.clientHeight / (element.height || element.clientHeight) * pixelRatio)
|
||||||
|
, 10)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue