Skip to content

Commit 1a01f67

Browse files
author
Gali Geller
committed
Added a new option to the plugin
With this option it is now possible to hide the slider while the video is playing
1 parent cf78fb9 commit 1a01f67

File tree

1 file changed

+27
-0
lines changed
  • packages/plugin-video-slider-response/src

1 file changed

+27
-0
lines changed

packages/plugin-video-slider-response/src/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ const info = <const>{
131131
pretty_name: "Response allowed while playing",
132132
default: true,
133133
},
134+
hide_slider_while_video_plays: {
135+
type: ParameterType.BOOL,
136+
pretty_name: "Hide slider while video plays",
137+
default: false,
138+
description: "If true the slider will be hidden while the video plays and it will appear when the video stops"
139+
},
134140
},
135141
};
136142

@@ -274,6 +280,10 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
274280
if (trial.trial_ends_after_video) {
275281
end_trial();
276282
} else if (!trial.response_allowed_while_playing) {
283+
if(trial.hide_slider_while_video_plays) {
284+
show_slider();
285+
}
286+
277287
enable_slider();
278288
}
279289
};
@@ -310,6 +320,10 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
310320
var currenttime = video_element.currentTime;
311321
if (currenttime >= trial.stop) {
312322
video_element.pause();
323+
if (trial.hide_slider_while_video_plays){
324+
show_slider();
325+
}
326+
313327
if (trial.trial_ends_after_video && !stopped) {
314328
// this is to prevent end_trial from being called twice, because the timeupdate event
315329
// can fire in quick succession
@@ -336,6 +350,11 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
336350
.addEventListener("touchstart", enable_button);
337351
}
338352

353+
if (trial.hide_slider_while_video_plays) {
354+
hide_slider();
355+
}
356+
357+
339358
var startTime = performance.now();
340359

341360
// store response
@@ -405,6 +424,14 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
405424
}
406425
}
407426

427+
function hide_slider() {
428+
(document.getElementsByClassName("jspsych-video-slider-response-container")[0] as HTMLElement).style.display = "none";
429+
}
430+
431+
function show_slider() {
432+
(document.getElementsByClassName("jspsych-video-slider-response-container")[0] as HTMLElement).style.display = "";
433+
}
434+
408435
// end trial if time limit is set
409436
if (trial.trial_duration !== null) {
410437
this.jsPsych.pluginAPI.setTimeout(end_trial, trial.trial_duration);

0 commit comments

Comments
 (0)