diff --git a/css/jspsych.css b/css/jspsych.css index 20d10905..9a07da4d 100644 --- a/css/jspsych.css +++ b/css/jspsych.css @@ -96,6 +96,79 @@ cursor: not-allowed; } +/* custom style for input[type="range] (slider) to improve alignment between positions and labels */ + +.jspsych-slider { + appearance: none; + -webkit-appearance: none; + -moz-appearance: none; + width: 100%; + background: transparent; +} +.jspsych-slider:focus { + outline: none; +} +/* track */ +.jspsych-slider::-webkit-slider-runnable-track { + appearance: none; + -webkit-appearance: none; + width: 100%; + height: 8px; + cursor: pointer; + background: #eee; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border-radius: 2px; + border: 1px solid #aaa; +} +.jspsych-slider::-moz-range-track { + appearance: none; + width: 100%; + height: 8px; + cursor: pointer; + background: #eee; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border-radius: 2px; + border: 1px solid #aaa; +} +.jspsych-slider::-ms-track { + appearance: none; + width: 99%; + height: 14px; + cursor: pointer; + background: #eee; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border-radius: 2px; + border: 1px solid #aaa; +} +/* thumb */ +.jspsych-slider::-webkit-slider-thumb { + border: 1px solid #666; + height: 24px; + width: 15px; + border-radius: 5px; + background: #ffffff; + cursor: pointer; + -webkit-appearance: none; + margin-top: -9px; +} +.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; +} + /* jsPsych progress bar */ #jspsych-progressbar-container { diff --git a/plugins/jspsych-audio-slider-response.js b/plugins/jspsych-audio-slider-response.js index 16ced91c..40f2a5f2 100644 --- a/plugins/jspsych-audio-slider-response.js +++ b/plugins/jspsych-audio-slider-response.js @@ -93,6 +93,9 @@ jsPsych.plugins['audio-slider-response'] = (function() { plugin.trial = function(display_element, trial) { + // half of the thumb width value from jspsych.css, used to adjust the label positions + var half_thumb_width = 7.5; + // setup stimulus var context = jsPsych.pluginAPI.audioContext(); if(context !== null){ @@ -123,20 +126,25 @@ jsPsych.plugins['audio-slider-response'] = (function() { } var html = '