Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap drawing in requestAnimationFrame (multicanvas). #1106

Merged
merged 12 commits into from
Jun 11, 2017
8 changes: 4 additions & 4 deletions src/drawer.multicanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {
}
},

drawBars: function (peaks, channelIndex, start, end) {
drawBars: utils.frame(function(peaks, channelIndex, start, end) {
// Split channels
if (peaks[0] instanceof Array) {
var channels = peaks;
Expand Down Expand Up @@ -231,15 +231,15 @@ 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) {
drawLine: utils.frame(function(peaks, absmax, halfH, offsetY, start, end) {
Copy link
Owner

Choose a reason for hiding this comment

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

utils is undefined. It has to be WaveSurfer.util. Please also restore the spaces after the function keyword.

this.canvases.forEach (function (entry) {
this.setFillStyles(entry);
this.drawLineToContext(entry, entry.waveCtx, peaks, absmax, halfH, offsetY, start, end);
this.drawLineToContext(entry, entry.progressCtx, peaks, absmax, halfH, offsetY, start, end);
}, this);
},
}),

drawLineToContext: function (entry, ctx, peaks, absmax, halfH, offsetY, start, end) {
if (!ctx) { return; }
Expand Down