Skip to content

Commit

Permalink
Wrap drawing in requestAnimationFrame (multicanvas). (#1106)
Browse files Browse the repository at this point in the history
* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* I have no idea why this failed.

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js
  • Loading branch information
agamemnus authored and katspaugh committed Jun 11, 2017
1 parent 29fd88d commit d9f3394
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/drawer.multicanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {
}
},

drawBars: function (peaks, channelIndex, start, end) {
drawBars: WaveSurfer.util.frame(function (peaks, channelIndex, start, end) {
// Split channels
if (peaks[0] instanceof Array) {
var channels = peaks;
Expand Down Expand Up @@ -189,9 +189,9 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {
var h = Math.round(peak / absmax * halfH);
this.fillRect(i + this.halfPixel, halfH - h + offsetY, bar + this.halfPixel, h * 2);
}
},
}),

drawWave: function (peaks, channelIndex, start, end) {
drawWave: WaveSurfer.util.frame(function (peaks, channelIndex, start, end) {
// Split channels
if (peaks[0] instanceof Array) {
var channels = peaks;
Expand Down Expand Up @@ -233,7 +233,7 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {

// Always draw a median line
this.fillRect(0, halfH + offsetY - this.halfPixel, this.width, this.halfPixel);
},
}),

drawLine: function (peaks, absmax, halfH, offsetY, start, end) {
this.canvases.forEach (function (entry) {
Expand Down

2 comments on commit d9f3394

@thijstriemstra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katspaugh when squashing and merging a PR like this, can you make sure to strip out any non-sense commit messages from the final commit? E.g. this is not really useful to include in a merge commit:

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* I have no idea why this failed.

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

* Update drawer.multicanvas.js

@katspaugh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, that's what GitHub does. I don't think I want to manually squash/merge, sorry. 😀

Please sign in to comment.