Modifying html-slider-response #1660
-
Hi! I'm looking for some advice on how would I go about modifying slider-response plugin, so that:
Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hi @j22tis! To hide the slider thumb, you can remove the CSS rules that set the custom thumb appearance in the jspsych.css file, i.e. the commented-out stuff below. The only bit you want to keep is the /* thumb */
.jspsych-slider::-webkit-slider-thumb {
/* border: 1px solid #666;
height: 24px;
width: 15px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
margin-top: -9px; */
-webkit-appearance: none;
}
/* .jspsych-slider::-moz-range-thumb {
border: 1px solid #666;
height: 24px;
width: 15px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
}
.jspsych-slider::-ms-thumb {
border: 1px solid #666;
height: 20px;
width: 15px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
margin-top: -2px;
} */ I think you also need to set the .jspsych-slider::-ms-thumb {visibility: hidden;}
.jspsych-slider::-moz-range-thumb {visibility:hidden;} To get the trial to end when the slider is clicked, you can find the line in the plugin that sets up the click event listener for the next button (line 153 in html-slider-response in jsPsych v6.3.0): display_element.querySelector('#jspsych-html-slider-response-next').addEventListener('click', function() { ... } And change this so that the click handler function is applied to the slider instead of the next button. The slider ID is "jspsych-html-slider-response-response", so you would change that line to this: display_element.querySelector('#jspsych-html-slider-response-response').addEventListener('click', function() { ... } Then as long as the trial's The trickier part is getting the thumb to reappear when the slider has been clicked. This is tricky because you can't use JavaScript to set CSS rules for pseudo-classes in the same way that you can for other CSS selectors. But if I understand correctly, it sounds like you want the trial to end anyway when the person clicks the slider, so maybe showing the thumb isn't that important? If it is, you can have a look at the responses to this stackoverflow post about setting CSS pseudo-class rules with JavaScript, and then add the code for this inside the slider's click event handler. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi! For quite some time I've been struggling a bit with the fact that the standard html-slider-response needs to have a starting position and often ended looking at this thread but then felt a bit intimidated by my lack of knowledge of CSS. But eventually I learned some basics and made a modified version of the original plugin which implements this change. So if anyone is looking for it you can find it here: It doesn't implement the second change mentioned by @becky-gilbert, because I didn't need it, but if someone needs the jsPsych slider without a marker's starting position then it might save them some time. It was based on the solutions proposed by @cvanheer and involved two things:
EDIT: The new version allows to control whether the starting position is visible or not. This option can by turned on or off by manipulating the parameter I tested it on jsPsych 7.1.2 and jsPsych 7.3 |
Beta Was this translation helpful? Give feedback.
Hi @j22tis! To hide the slider thumb, you can remove the CSS rules that set the custom thumb appearance in the jspsych.css file, i.e. the commented-out stuff below. The only bit you want to keep is the
-webkit-appearance: none;
for.jspsych-slider::-webkit-slider-thumb
: