jspsych/plugins/jspsych-rdk.js
//Function to make the dots move on the canvas

Function to make the dots move on the canvas
Function to make the dots move on the canvas
function animateDotMotion() {
			var frameRequestID = window.requestAnimationFrame(animate);
			startKeyboardListener(); 
			var previousTimestamp;
			function animate() {
				if (stopDotMotion) {
					window.cancelAnimationFrame(frameRequestID); 
				}
				else {
					frameRequestID = window.requestAnimationFrame(animate); 
					if ( (!timerHasStarted) && (trial.trial_duration > 0) ){
						timeoutID = window.setTimeout(end_trial,trial.trial_duration); 
						timerHasStarted = true;
					}
					updateAndDraw(); 
					if(previousTimestamp === undefined){
						previousTimestamp = performance.now();
					}
					else{
						var currentTimeStamp = performance.now(); 
						frameRate.push(currentTimeStamp - previousTimestamp); 
						previousTimestamp = currentTimeStamp; 
					}
				}
			}
		}
function animateDotMotion ( ) { var frameRequestID = window . requestAnimationFrame ( animate ) ; startKeyboardListener ( ) ; var previousTimestamp ; function animate ( ) { if ( stopDotMotion ) { window . cancelAnimationFrame ( frameRequestID ) ; } else { frameRequestID = window . requestAnimationFrame ( animate ) ; if ( ( ! timerHasStarted ) && ( trial . trial_duration > 0 ) ) { timeoutID = window . setTimeout ( end_trial , trial . trial_duration ) ; timerHasStarted = true ; } updateAndDraw ( ) ; if ( previousTimestamp === undefined ) { previousTimestamp = performance . now ( ) ; } else { var currentTimeStamp = performance . now ( ) ; frameRate . push ( currentTimeStamp - previousTimestamp ) ; previousTimestamp = currentTimeStamp ; } } } }
Function to make the dots move on the canvas
Function to make the dots move on the canvas
//frameRequestID saves a long integer that is the ID of this frame request. The ID is then used to terminate the request below.
 //Start to listen to subject's key responses
 //Delare a timestamp
 //If stopping condition has been reached, then stop the animation
 //Cancels the frame request
 //Else continue with another frame request
 //Calls for another frame request
 //If the timer has not been started and it is set, then start the timer
 //If the trial duration is set, then set a timer to count down and call the end_trial function when the time is up
 //(If the subject did not press a valid keyboard response within the trial duration, then this will end the trial)
 //This timeoutID is then used to cancel the timeout should the subject press a valid key
 //The timer has started, so we set the variable to true so it does not start more timers
 //Update and draw each of the dots in their respective apertures
 //If this is before the first frame, then start the timestamp
 //Else calculate the time and push it into the array
 //Variable to hold current timestamp
 //Push the interval into the frameRate array
 //Reset the timestamp
