1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00

Merge pull request #501 from lightest/CU-2au7jh3_slider_start_val

Starting val doesn't appear online
This commit is contained in:
Alain Pitiot 2022-06-15 14:13:58 +02:00 committed by GitHub
commit 460b564699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,7 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin)
style,
ticks,
labels,
startValue,
granularity,
flip,
readOnly,
@ -141,6 +142,11 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin)
[],
onChange(true, true, true),
);
this._addAttribute(
"startValue",
startValue,
undefined
);
this._addAttribute(
"granularity",
granularity,
@ -949,7 +955,27 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin)
// marker:
this._marker = new PIXI.Graphics();
this._marker.alpha = 0; // invisible until markerPos is defined
let markerVal = undefined;
if (Number.isFinite(this._rating))
{
markerVal = this._rating;
}
else if (Number.isFinite(this._startValue))
{
markerVal = this._startValue;
}
if (Number.isFinite(markerVal))
{
this._markerPos = this._granularise(markerVal);
const visibleMarkerPos = this._ratingToPos([this._markerPos]);
this._marker.position = to_pixiPoint(visibleMarkerPos[0], this.units, this.win, true);
}
else
{
this._marker.alpha = 0; // invisible until markerPos is defined
}
this._marker.interactive = true;
this._pixi.addChild(this._marker);