@@ -31,8 +31,8 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
31
31
const ticks = showLabels ? this . getTicks ( ) : null ;
32
32
33
33
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 ) ) ;
36
36
37
37
const rangeLeftPercent = leftPercent + "%" ;
38
38
const rangeRightPercent = ( 100 - rightPercent ) + "%" ;
@@ -130,22 +130,25 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
130
130
private getPercent ( value :number ) :number {
131
131
const { max, min } = this . question ;
132
132
const fullRange = max - min ;
133
- return ( ( value - min ) / fullRange ) * 100 ;
133
+ return ( Math . abs ( value - min ) / fullRange ) * 100 ;
134
134
}
135
135
136
136
private getRenderedValue ( ) {
137
137
const { max, min, renderedmaxRangeLength : maxRangeLength , sliderType } = this . question ;
138
- let result = this . question . value . slice ( ) ;
138
+ let result ;
139
139
140
140
if ( sliderType === "single" ) {
141
+ result = this . question . value ;
141
142
if ( typeof result === "undefined" || result . length === 0 ) {
142
143
this . question . isIndeterminate = true ;
143
- return [ min ] ;
144
+ return min >= 0 ? [ min ] : [ 0 ] ;
144
145
} else {
145
146
return [ result ] ;
146
147
}
147
148
}
148
149
150
+ result = this . question . value . slice ( ) ;
151
+
149
152
if ( result . length === 0 ) {
150
153
const fullRange = max - min ;
151
154
this . question . isIndeterminate = true ;
@@ -158,6 +161,7 @@ export class SurveyQuestionSlider extends SurveyQuestionElementBase {
158
161
159
162
private refreshInputRange ( ) {
160
163
if ( ! this . question . allowDragRange ) return ;
164
+ if ( ! this . rangeInputRef . current ) return ;
161
165
const renderedValue = this . getRenderedValue ( ) ;
162
166
const percentLastValue = this . getPercent ( renderedValue [ renderedValue . length - 1 ] ) ;
163
167
const percentFirstValue = this . getPercent ( renderedValue [ 0 ] ) ;
0 commit comments