Skip to content

Commit

Permalink
cursor plugin: fix displayed time (katspaugh#1543)
Browse files Browse the repository at this point in the history
* Fix time

* Rename variable

* Format code
  • Loading branch information
michaeljscript authored and thijstriemstra committed Dec 29, 2018
1 parent 946cdc5 commit 266b448
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugin/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ export default class CursorPlugin {
});
if (this.params.showTime) {
const duration = this.wavesurfer.getDuration();
const timeValue = (pos / this.wavesurfer.drawer.width) * duration;
const elementWidth =
this.wavesurfer.drawer.getWidth() /
this.wavesurfer.params.pixelRatio;
const timeValue = Math.max(0, (pos / elementWidth) * duration);
const formatValue = this.formatTime(timeValue);
this.style(this.showTime, {
left: `${pos}px`
Expand Down

0 comments on commit 266b448

Please sign in to comment.