mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
fix cases where timeouts fire after expected event
This commit is contained in:
parent
308a791a8a
commit
e8f1bd6d08
@ -96,9 +96,10 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
|
||||
}
|
||||
|
||||
private hideStimulus(display_element: HTMLElement) {
|
||||
display_element.querySelector<HTMLElement>(
|
||||
"#jspsych-html-audio-response-stimulus"
|
||||
).style.visibility = "hidden";
|
||||
const el: HTMLElement = display_element.querySelector("#jspsych-html-audio-response-stimulus");
|
||||
if (el) {
|
||||
el.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
private addButtonEvent(display_element, trial) {
|
||||
@ -155,13 +156,17 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
|
||||
// setup timer for ending the trial
|
||||
if (trial.recording_duration !== null) {
|
||||
this.jsPsych.pluginAPI.setTimeout(() => {
|
||||
this.stopRecording().then(() => {
|
||||
if (trial.allow_playback) {
|
||||
this.showPlaybackControls(display_element, trial);
|
||||
} else {
|
||||
this.endTrial(display_element, trial);
|
||||
}
|
||||
});
|
||||
// this check is necessary for cases where the
|
||||
// done_button is clicked before the timer expires
|
||||
if (this.recorder.state !== "inactive") {
|
||||
this.stopRecording().then(() => {
|
||||
if (trial.allow_playback) {
|
||||
this.showPlaybackControls(display_element, trial);
|
||||
} else {
|
||||
this.endTrial(display_element, trial);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, trial.recording_duration);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user