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) {
|
private hideStimulus(display_element: HTMLElement) {
|
||||||
display_element.querySelector<HTMLElement>(
|
const el: HTMLElement = display_element.querySelector("#jspsych-html-audio-response-stimulus");
|
||||||
"#jspsych-html-audio-response-stimulus"
|
if (el) {
|
||||||
).style.visibility = "hidden";
|
el.style.visibility = "hidden";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private addButtonEvent(display_element, trial) {
|
private addButtonEvent(display_element, trial) {
|
||||||
@ -155,13 +156,17 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
|
|||||||
// setup timer for ending the trial
|
// setup timer for ending the trial
|
||||||
if (trial.recording_duration !== null) {
|
if (trial.recording_duration !== null) {
|
||||||
this.jsPsych.pluginAPI.setTimeout(() => {
|
this.jsPsych.pluginAPI.setTimeout(() => {
|
||||||
this.stopRecording().then(() => {
|
// this check is necessary for cases where the
|
||||||
if (trial.allow_playback) {
|
// done_button is clicked before the timer expires
|
||||||
this.showPlaybackControls(display_element, trial);
|
if (this.recorder.state !== "inactive") {
|
||||||
} else {
|
this.stopRecording().then(() => {
|
||||||
this.endTrial(display_element, trial);
|
if (trial.allow_playback) {
|
||||||
}
|
this.showPlaybackControls(display_element, trial);
|
||||||
});
|
} else {
|
||||||
|
this.endTrial(display_element, trial);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}, trial.recording_duration);
|
}, trial.recording_duration);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user