0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-14 00:38:41 -04:00
This commit is contained in:
Nuño de la Serna 2024-09-17 19:40:28 +02:00 committed by GitHub
commit c9011eee30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,7 +34,7 @@ var Common = require('../core/Common');
mouse.scale = { x: 1, y: 1 };
mouse.wheelDelta = 0;
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 = {
mousemove: null,
@ -192,9 +192,13 @@ var Common = require('../core/Common');
y = event.pageY - elementBounds.top - scrollY;
}
return {
x: x / (element.clientWidth / (element.width || element.clientWidth) * pixelRatio),
y: y / (element.clientHeight / (element.height || element.clientHeight) * pixelRatio)
return {
x: parseInt(
x / (element.clientWidth / (element.width || element.clientWidth) * pixelRatio)
, 10),
y: parseInt(
y / (element.clientHeight / (element.height || element.clientHeight) * pixelRatio)
, 10)
};
};