Skip to content

Commit

Permalink
Correction to when to detect when canvas contents are offscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Feb 28, 2022
1 parent 171f38d commit abe7d4e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/util/offscreenCanvasPonyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ export class PonyfillOffscreenContext {

fillRect(...args) {
const [x, y, w, h] = args

// avoid rendering offscreen contents
if (x > this.width || x + w < 0) {
return
}

const nx = Math.max(x, 0)
const nw = nx + w > this.width ? this.width - nx : w
const nw = w - (nx - x)
this.commands.push({ type: 'fillRect', args: [nx, y, nw, h] })
}

Expand Down

0 comments on commit abe7d4e

Please sign in to comment.