Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 36b03f2

Browse files
devversionjelbourn
authored andcommitted
fix(ripple): calculate relative coordinates from ripple target.
If there are any children the `offsetX` and `offsetY` are wrong, because it's not relative to the ripple target. We can fix that by calculating `layerX` and `layerY`. As the normal `layerX` and `layerY` is not a W3C Standard (and is deprecated) we need to calculate our coordinates our self. Fixes #5917 Closes #6092
1 parent cb2bc6a commit 36b03f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/core/services/ripple/ripple.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,17 @@ InkRippleCtrl.prototype.handleMousedown = function (event) {
259259
if (this.options.center) {
260260
this.createRipple(this.container.prop('clientWidth') / 2, this.container.prop('clientWidth') / 2);
261261
} else {
262-
this.createRipple(event.offsetX, event.offsetY);
262+
263+
// We need to calculate the relative coordinates if the target is a sublayer of the ripple element
264+
if (event.srcElement !== this.$element[0]) {
265+
var layerRect = this.$element[0].getBoundingClientRect();
266+
var layerX = event.clientX - layerRect.left;
267+
var layerY = event.clientY - layerRect.top;
268+
269+
this.createRipple(layerX, layerY);
270+
} else {
271+
this.createRipple(event.offsetX, event.offsetY);
272+
}
263273
}
264274
};
265275

0 commit comments

Comments
 (0)