I have integrated a javascript audioplayer in a website, and it worked without problems. But ever since i limited the width of the webpage with a container div ('max-width'), the clickable timeline is not working correctly.
I narrowed down the problem, i think. This code calculates the mouseclick on the timeline:
function clickPercent(e) {
return (e.pageX - timeline.offsetLeft) / timelineWidth;
}
The problem is that pageX counts from the left browser edge, offsetLeft on the other hand counts from the parent element's edge. So when i click on the timeline, the player-dot jumps to the wrong position.
I made a JSfiddle demo: http://jsfiddle.net/2zkj25ss/35/
I suppose that i need something different than offsetLeft, something that can give me the absolute offset instead of the relative offset.
Can anyone help me with this? Please keep in mind that i'm not a programmer, and my JavaScript skills range from poor to non-existent.