Skip to content

Commit 7dce8c0

Browse files
work for the #9023
1 parent 1703244 commit 7dce8c0

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

packages/survey-core/src/default-theme/blocks/sd-slider.scss

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ $range-slider-thumb-size: 20px;
2020
}
2121
}
2222

23-
.sd-slider--single {
24-
.sd-slider__inverse-track--left {
25-
background-color: $primary;
26-
}
27-
}
23+
.sd-slider--single {}
2824

2925
.sd-slider__visual-slider-container {
3026
position: absolute;
@@ -37,23 +33,25 @@ $range-slider-thumb-size: 20px;
3733
.sd-slider__inverse-track {
3834
position: absolute;
3935
height: $range-slider-height;
40-
border-radius: 10px;
4136
background-color: $foreground-light;
4237
}
4338

4439
.sd-slider__inverse-track--left {
4540
left: 0;
41+
border-top-left-radius: 10px;
42+
border-bottom-left-radius: 10px;
4643
}
4744

4845
.sd-slider__inverse-track--right {
4946
right: 0;
47+
border-top-right-radius: 10px;
48+
border-bottom-right-radius: 10px;
5049
}
5150

5251
.sd-slider__range-track {
5352
position: absolute;
5453
left: 0;
5554
height: $range-slider-height;
56-
border-radius: 14px;
5755
background-color: $primary;
5856
}
5957

packages/survey-react-ui/src/reactquestion_slider.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
3131
const ticks = showLabels ? this.getTicks() : null;
3232

3333
const value = this.getRenderedValue();
34-
const leftPercent = this.getPercent(Math.min(...value));
35-
const rightPercent = this.getPercent(Math.max(...value));
34+
const leftPercent = sliderType === "single" ? this.getPercent(Math.min(value, 0)) : this.getPercent(Math.min(...value));
35+
const rightPercent = sliderType === "single" ? this.getPercent(Math.max(value, 0)) : this.getPercent(Math.max(...value));
3636

3737
const rangeLeftPercent = leftPercent + "%";
3838
const rangeRightPercent = (100 - rightPercent) + "%";
@@ -130,22 +130,25 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
130130
private getPercent(value:number):number {
131131
const { max, min } = this.question;
132132
const fullRange = max - min;
133-
return ((value - min)/fullRange)*100;
133+
return (Math.abs(value - min)/fullRange)*100;
134134
}
135135

136136
private getRenderedValue() {
137137
const { max, min, renderedmaxRangeLength: maxRangeLength, sliderType } = this.question;
138-
let result = this.question.value.slice();
138+
let result;
139139

140140
if (sliderType === "single") {
141+
result = this.question.value;
141142
if (typeof result === "undefined" || result.length === 0) {
142143
this.question.isIndeterminate = true;
143-
return [min];
144+
return min >= 0 ? [min] : [0];
144145
} else {
145146
return [result];
146147
}
147148
}
148149

150+
result = this.question.value.slice();
151+
149152
if (result.length === 0) {
150153
const fullRange = max - min;
151154
this.question.isIndeterminate = true;
@@ -158,6 +161,7 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
158161

159162
private refreshInputRange() {
160163
if (!this.question.allowDragRange) return;
164+
if (!this.rangeInputRef.current) return;
161165
const renderedValue = this.getRenderedValue();
162166
const percentLastValue = this.getPercent(renderedValue[renderedValue.length - 1]);
163167
const percentFirstValue = this.getPercent(renderedValue[0]);

0 commit comments

Comments
 (0)