0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-21 17:14:38 -05:00

Adds Firefox support for mouse on SVG elements (#1)

* Adds Firefox support for mouse on SVG elements

Firefox follows the spec [here](https://www.w3.org/TR/cssom-view-1/#dom-element-clientwidth), so `clientWidth` isn't reliable.
This commit is contained in:
Adam Lovatt 2019-02-13 09:44:38 -07:00 committed by Spenser Jones
parent e994bd7b4f
commit 9872163829

View file

@ -182,8 +182,8 @@ var Common = require('../core/Common');
scrollX = (window.pageXOffset !== undefined) ? window.pageXOffset : rootNode.scrollLeft,
scrollY = (window.pageYOffset !== undefined) ? window.pageYOffset : rootNode.scrollTop,
touches = event.changedTouches,
elementWidth = element.width || element.clientWidth,
elementHeight = element.height || element.clientHeight,
elementWidth = element.width || element.clientWidth || elementBounds.width,
elementHeight = element.height || element.clientHeight || elementBounds.height,
x, y;
if (touches) {
@ -200,8 +200,8 @@ var Common = require('../core/Common');
}
return {
x: x / (element.clientWidth / elementWidth * pixelRatio),
y: y / (element.clientHeight / elementHeight * pixelRatio)
x: x / ((element.clientWidth || elementBounds.width) / elementWidth * pixelRatio),
y: y / ((element.clientHeight || elementBounds.height) / elementHeight * pixelRatio)
};
};