jsPsych icon indicating copy to clipboard operation
jsPsych copied to clipboard

showing slider value during slider movement

Open CrumpLab opened this issue 6 years ago • 4 comments

I didn't see an option for displaying the current value of the slider while it is being moved. Have I missed it?

CrumpLab avatar Aug 15 '19 19:08 CrumpLab

No, that's not currently implemented. If you have a small number of values then you can make the number of steps equal to the number of labels.

jodeleeuw avatar Aug 15 '19 19:08 jodeleeuw

@stefanuddenberg has implemented this and a few other improvements. @jodeleeuw: should I ask him to submit a pull request?

jcpeterson avatar Apr 06 '20 17:04 jcpeterson

Got a solution. Not a very general one but it's simple and works for me. I'm adding this comment here in case anyone stumbles on this trying to find a solution or if someone with real dev skills needs an idea to move forward with a more general solution.

I wanted this function in the html-slider-response. Got it to work using the stimulus parameter to house/present the slider value (meaning no other stimulus value). I initialize the stimulus parameter with "" and have it update whenever the slider is changed by adding the code below to the html-slider-response plugin file just before "if(trial.require_movement){".

That was it really. The current slider value appears just above the slider every time the slider is clicked on. I'm sure if someone spent some more time that they could improve the functionality but this suits my problem and maybe other people's.

display_element.querySelector('#jspsych-html-slider-response-response').addEventListener('click', function(){ //console.log(display_element.querySelector('#jspsych-html-slider-response-response').valueAsNumber); // for testing display_element.querySelector('#jspsych-html-slider-response-stimulus').textContent = display_element.querySelector('#jspsych-html-slider-response-response').valueAsNumber; });

SmithBradleyC avatar May 13 '21 02:05 SmithBradleyC

See #1192 and #1701 for some <=7.0 implementations.

jodeleeuw avatar Dec 14 '21 16:12 jodeleeuw