mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-12 08:38:10 +00:00
visual/Form: add Form.Type.SLIDER support
This commit is contained in:
parent
2776ad417f
commit
19c062c77c
@ -346,7 +346,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
const responseStim = this._visual.responseStims[i];
|
const responseStim = this._visual.responseStims[i];
|
||||||
if (responseStim)
|
if (responseStim)
|
||||||
{
|
{
|
||||||
if (item.type === Form.Types.CHOICE || item.type === Form.Types.RATING)
|
if (item.type === Form.Types.CHOICE || item.type === Form.Types.RATING || item.type === Form.Types.SLIDER)
|
||||||
{
|
{
|
||||||
item.response = responseStim.getRating();
|
item.response = responseStim.getRating();
|
||||||
item.rt = responseStim.getRT();
|
item.rt = responseStim.getRT();
|
||||||
@ -560,7 +560,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
delete item.questionWidth;
|
delete item.questionWidth;
|
||||||
|
|
||||||
// for items of type 'rating, the ticks are in 'options' instead of in 'ticks':
|
// for items of type 'rating, the ticks are in 'options' instead of in 'ticks':
|
||||||
if (item.type === 'rating')
|
if (item.type === 'rating' || item.type === 'slider')
|
||||||
{
|
{
|
||||||
item.ticks = item.options;
|
item.ticks = item.options;
|
||||||
item.options = undefined;
|
item.options = undefined;
|
||||||
@ -632,7 +632,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// turn the ticks and tickLabels into arrays, where applicable:
|
// turn the ticks and tickLabels into arrays, where applicable:
|
||||||
else if (item.type === Form.Types.RATING)
|
else if (item.type === Form.Types.RATING || item.type === Form.Types.SLIDER)
|
||||||
{
|
{
|
||||||
item.ticks = item.ticks.split(',').map( (_,t) => parseInt(t) );
|
item.ticks = item.ticks.split(',').map( (_,t) => parseInt(t) );
|
||||||
item.tickLabels = (item.tickLabels.length > 0) ? item.tickLabels.split(',') : [];
|
item.tickLabels = (item.tickLabels.length > 0) ? item.tickLabels.split(',') : [];
|
||||||
@ -835,7 +835,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
const responseWidth = rowWidth * item.responseWidth;
|
const responseWidth = rowWidth * item.responseWidth;
|
||||||
|
|
||||||
// CHOICE and RATING
|
// CHOICE and RATING
|
||||||
if (item.type === Form.Types.CHOICE || item.type === Form.Types.RATING)
|
if (item.type === Form.Types.CHOICE || item.type === Form.Types.RATING || item.type === Form.Types.SLIDER)
|
||||||
{
|
{
|
||||||
let sliderSize;
|
let sliderSize;
|
||||||
if (item.layout === Form.Layout.HORIZONTAL)
|
if (item.layout === Form.Layout.HORIZONTAL)
|
||||||
@ -851,13 +851,20 @@ export class Form extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
flip = true;
|
flip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let style, labels, ticks;
|
let style, labels, ticks, granularity;
|
||||||
if (item.type === Form.Types.CHOICE)
|
if (item.type === Form.Types.CHOICE)
|
||||||
{
|
{
|
||||||
style = [Slider.Style.RATING, Slider.Style.RADIO];
|
style = [Slider.Style.RATING, Slider.Style.RADIO];
|
||||||
labels = item.options;
|
labels = item.options;
|
||||||
ticks = []; // categorical
|
ticks = []; // categorical
|
||||||
}
|
}
|
||||||
|
else if (item.type === Form.Types.SLIDER)
|
||||||
|
{
|
||||||
|
style = [Slider.Style.SLIDER];
|
||||||
|
labels = item.tickLabels;
|
||||||
|
ticks = item.ticks;
|
||||||
|
granularity = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style = [Slider.Style.RATING];
|
style = [Slider.Style.RATING];
|
||||||
|
Loading…
Reference in New Issue
Block a user