Skip to content

Commit

Permalink
timeline plugin: fix negative offset rendering (#2470)
Browse files Browse the repository at this point in the history
* timeline plugin: negative offset rendering issue

* add entry to changelog
  • Loading branch information
othmar52 committed Mar 4, 2022
1 parent 8d33268 commit 5af6502
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
wavesurfer.js changelog
=======================

6.0.4 (unreleased)
------------------
- Timeline plugin:
- Fix rendering issue for negative `offset` values (#2463)

6.0.3 (01.03.2022)
------------------
- Cursor plugin:
Expand Down
8 changes: 7 additions & 1 deletion src/plugin/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,13 @@ export default class TimelinePlugin {
// build an array of position data with index, second and pixel data,
// this is then used multiple times below
const positioning = [];
for (i = 0; i < totalSeconds / timeInterval; i++) {

// render until end in case we have a negative offset
const renderSeconds = (this.params.offset < 0)
? totalSeconds - this.params.offset
: totalSeconds;

for (i = 0; i < renderSeconds / timeInterval; i++) {
positioning.push([i, curSeconds, curPixel]);
curSeconds += timeInterval;
curPixel += pixelsPerSecond * timeInterval;
Expand Down

0 comments on commit 5af6502

Please sign in to comment.