From e857f2ec782d838fa6ebdcb96f85135fbc6d18e7 Mon Sep 17 00:00:00 2001 From: Abhinna Adhikari Date: Sat, 5 Dec 2020 14:01:37 -0500 Subject: [PATCH] Allow for dynamic change of speed during animation --- js/canvas.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/canvas.js b/js/canvas.js index c6fa9ec..8c289ae 100644 --- a/js/canvas.js +++ b/js/canvas.js @@ -14,7 +14,6 @@ canvas.height = window.innerHeight; var ctx = canvas.getContext('2d'); var dddState; //global variable for DDD state -var sliderVal; //global speed for packet(s) function drawEntities(allEntities) { // Given a list of entities in the system, draw them to the screen @@ -45,6 +44,7 @@ function runSim(packetArray, allEntities) { } function animatePacket(packets, allEntities) { + let sliderVal = document.getElementById('myRange').value; // global speed let map = new Map(); map[1] = 20; map[2] = 30; @@ -129,7 +129,6 @@ async function startSimulation() { dddState = document.getElementById('DDDstate').checked; //global variable for DDD state let nPorts = document.getElementById('nports').value; - sliderVal = document.getElementById('myRange').value; // global speed // Initialize the entity objects let garbage = new Garbage(700, 400);