Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add real-time value display feature to plugin-image-slider-response #3373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/plugin-image-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const info = <const>{
type: ParameterType.BOOL,
default: true,
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: true,
},
},
data: {
/** The path of the image that was displayed. */
Expand Down Expand Up @@ -222,7 +227,13 @@ class ImageSliderResponsePlugin implements JsPsychPlugin<Info> {
trial.max +
'" step="' +
trial.step +
'" id="jspsych-image-slider-response-response"></input>';
'" id="jspsych-image-slider-response-response" ';
if (trial.value_display) {
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + trial.slider_start + "</output>";
} else {
html += "></input>";
}
html += "<div>";
for (var j = 0; j < trial.labels.length; j++) {
var label_width_perc = 100 / (trial.labels.length - 1);
Expand Down