diff --git a/src/App.tsx b/src/App.tsx index b53661a..6199557 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,14 +5,15 @@ import "./App.css"; function App() { useEffect(() => { const canvas = document.getElementById("canvas"); - blastOff(canvas as HTMLCanvasElement); + const container = document.getElementById("container"); + blastOff(canvas as HTMLCanvasElement, container); }, []); return (

Synaptic

-
+

Simple React App Implementing the Synaptic Neural Network Library

diff --git a/src/lib/World.tsx b/src/lib/World.tsx index d827681..09d91b6 100644 --- a/src/lib/World.tsx +++ b/src/lib/World.tsx @@ -1,23 +1,15 @@ import { Creature } from "./Creature"; -import { isMobile } from "react-device-detect"; import { IWorld } from "./Interfaces"; -export function blastOff(canvas: HTMLCanvasElement | null) { - +export function blastOff(canvas: HTMLCanvasElement | null, container: HTMLElement | null) { var num = 20; var fps = 100; - if (canvas !== null) { + if (canvas !== null && container !== null) { var ctx = canvas.getContext('2d'); - if (isMobile) { - canvas.width = window.screen.width; - canvas.height = window.screen.height; - } - else { - canvas.width = window.innerWidth; - canvas.height = window.innerHeight; - } + canvas.width = container.offsetWidth; + canvas.height = container.offsetHeight; var world: IWorld = { creatures: [],