Skip to content

Commit

Permalink
fix(FEC-8503): seekbar virtual position is incorrect when positioned …
Browse files Browse the repository at this point in the history
…in a container with CSS transform (#268)

* getting the transformX of an element

* fix flow
  • Loading branch information
odedhutzler committed Aug 27, 2018
1 parent 76e29b2 commit 449d564
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/seekbar/seekbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class SeekBarControl extends Component {
let _x = 0;
let _y = 0;
while (element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) {
_x += element.offsetLeft - element.scrollLeft;
_x += element.offsetLeft - element.scrollLeft + this._getTransformX(element);
_y += element.offsetTop - element.scrollTop;
element = element.offsetParent;
}
Expand All @@ -332,6 +332,22 @@ class SeekBarControl extends Component {
return {top: _y, left: _x};
}

/**
* calculating the transform of an element
* @param {HTMLElement} element - the element to calculate the transform offset for
* @returns {number} - the transform
* @private
*/
_getTransformX(element: HTMLElement): number {
const transformValues = getComputedStyle(element).transform.match(/-?\d+/g);
// [scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY()]
let translateXVal = 0;
if (transformValues && transformValues.length > 0) {
translateXVal = parseFloat(transformValues[4]);
}
return translateXVal;
}

/**
* get current time based on position of the mouseEvent on the seekbar
*
Expand Down

0 comments on commit 449d564

Please sign in to comment.