diff --git a/src/index.tsx b/src/index.tsx index 78f98840..69bccb67 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -361,9 +361,9 @@ function renderScene( const fillStyle = context.fillStyle; if (typeof sceneState.viewBackgroundColor === "string") { context.fillStyle = sceneState.viewBackgroundColor; - context.fillRect(-0.5, -0.5, canvas.width, canvas.height); + context.fillRect(0, 0, canvas.width, canvas.height); } else { - context.clearRect(-0.5, -0.5, canvas.width, canvas.height); + context.clearRect(0, 0, canvas.width, canvas.height); } context.fillStyle = fillStyle; @@ -409,8 +409,8 @@ function renderScene( if (renderScrollbars) { const scrollBars = getScrollbars( - context.canvas.width, - context.canvas.height, + context.canvas.width / window.devicePixelRatio, + context.canvas.height / window.devicePixelRatio, sceneState.scrollX, sceneState.scrollY ); @@ -801,6 +801,9 @@ const someElementIsSelected = () => const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5; const ELEMENT_TRANSLATE_AMOUNT = 1; +let lastCanvasWidth = -1; +let lastCanvasHeight = -1; + class App extends React.Component<{}, AppState> { public componentDidMount() { document.addEventListener("keydown", this.onKeyDown, false); @@ -941,6 +944,9 @@ class App extends React.Component<{}, AppState> { private removeWheelEventListener: (() => void) | undefined; public render() { + const canvasWidth = window.innerWidth - CANVAS_WINDOW_OFFSET_LEFT; + const canvasHeight = window.innerHeight - CANVAS_WINDOW_OFFSET_TOP; + return (