diff --git a/src/render.js b/src/render.js index d75d3ef..18bd571 100644 --- a/src/render.js +++ b/src/render.js @@ -62,7 +62,7 @@ export class Renderer { canvas.height = Math.round(displayHeight * dpr); // Maintain your display size - canvas.style.width = `${displayWidth}px`; + canvas.style.width = `${displayWidth }px`; canvas.style.height = `${displayHeight}px`; // Scale context to compensate @@ -79,6 +79,7 @@ export class Renderer { const rect = this.timeIndicator.getBoundingClientRect(); const sheetLeft = this.sheetWindow.getBoundingClientRect().left; + const sheetRight = this.sheetWindow.getBoundingClientRect().right; const xPosition = rect.left + window.scrollX - sheetLeft; const canvasEntry = this.canvases[this.currStaveNumber - 1]; @@ -91,6 +92,8 @@ export class Renderer { const width = instrument.width * this.iconScale; const height = instrument.height * this.iconScale; + if(xPosition + width > sheetRight) xPosition -= width; + ctx.drawImage(instrument.image, xPosition, y, width, height); this.iconCache.push({