player.js: Fix marker sub-element hover xoffset

This commit is contained in:
Matt Mascarenhas 2017-06-18 22:42:11 +01:00
parent b920a1e5e9
commit 3749294def
1 changed files with 9 additions and 1 deletions

View File

@ -172,9 +172,17 @@ Player.prototype.onMarkerClick = function(marker, ev) {
this.play();
};
function getElementXOffsetFromPage(el) {
var left = 0;
do {
left += el.offsetLeft;
} while (el = el.offsetParent);
return left;
}
Player.prototype.onMarkerMouseMove = function(marker, ev) {
if (this.currentMarker == marker) {
marker.hoverx = (ev.offsetX - marker.el.offsetLeft) / marker.el.offsetWidth;
marker.hoverx = (ev.pageX - getElementXOffsetFromPage(marker.el)) / marker.el.offsetWidth;
}
};