Skip to content

Commit

Permalink
Added time label configurable params
Browse files Browse the repository at this point in the history
  • Loading branch information
nabiulin committed Dec 23, 2015
1 parent b93ec64 commit 289f167
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions example/timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ <h4>Options</h4>
<li><code>secondaryColor</code> - the color of the non-modulo-ten notch lines. The default is '#c0c0c0'.</li>
<li><code>primaryFontColor</code> - the color of the non-modulo-ten time labels (e.g. 10sec, 20sec). The default is '#000'.</li>
<li><code>primaryFontColor</code> - the color of the non-modulo-ten time labels (e.g. 5sec, 15sec). The default is '#c0c0c0'.</li>
<li><code>fontFamily</code> - the font family for the time labels. The default is 'Arial'.</li>
<li><code>fontSize</code> - the font size for the time labels. The default is 10.</li>
<li><code>timeInterval</code> - number of intervals that records consists of. Usually it is equal to the duration in minutes.</li>
<li><code>primaryLabelInterval</code> - number of primary time labels.</li>
<li><code>secondaryLabelInterval</code> - number of secondary time labels (Time labels between primary labels).</li>
</ul>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions plugin/wavesurfer.timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
this.secondaryFontColor = this.params.secondaryFontColor || '#000';
this.fontFamily = this.params.fontFamily || 'Arial';
this.fontSize = this.params.fontSize || 10;
this.timeInterval = this.params.timeInterval;
this.primaryLabelInterval = this.params.primaryLabelInterval;
this.secondaryLabelInterval = this.params.secondaryLabelInterval;

this.createWrapper();
this.createCanvas();
Expand Down Expand Up @@ -157,6 +160,10 @@
var secondaryLabelInterval = 2;
}

timeInterval = this.timeInterval || timeInterval;
primaryLabelInterval = this.primaryLabelInterval || primaryLabelInterval;
secondaryLabelInterval = this.secondaryLabelInterval || secondaryLabelInterval;

var height1 = this.height - 4,
height2 = (this.height * (this.notchPercentHeight / 100.0)) - 4,
fontSize = this.fontSize * wsParams.pixelRatio;
Expand Down

0 comments on commit 289f167

Please sign in to comment.