Skip to content

Commit cb54754

Browse files
committed
Changed nouislider
Changed to one slider handle Changed default value to middle of range Added step option Added slider value tooltip Added scale
1 parent 2f7ef0f commit cb54754

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/nouislider.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,33 @@ function init(Survey) {
1515
activatedByChanged: function(activatedBy) {
1616
Survey.JsonObject.metaData.addClass("nouislider", [], null, "empty");
1717
Survey.JsonObject.metaData.addProperties("nouislider", [
18+
{
19+
name: "step:number",
20+
default: 1
21+
},
1822
{
1923
name: "rangeMin:number",
2024
default: 0
2125
},
2226
{
2327
name: "rangeMax:number",
2428
default: 100
25-
},
26-
{
27-
name: "defaultRangeMin:number",
28-
default: 30
29-
},
30-
{
31-
name: "defaultRangeMax:number",
32-
default: 70
3329
}
3430
]);
3531
},
3632
afterRender: function(question, el) {
37-
var startValue = question.value;
38-
if (!startValue || startValue.length != 2) {
39-
startValue = [question.defaultRangeMin, question.defaultRangeMax];
40-
}
41-
if (startValue[0] < question.rangeMin) startValue[0] = question.rangeMin;
42-
if (startValue[0] > question.rangeMax) startValue[0] = question.rangeMax;
43-
if (startValue[1] < startValue[0]) startValue[1] = startValue[0];
44-
if (startValue[1] > question.rangeMax) startValue[1] = question.rangeMax;
45-
question.value = startValue;
33+
question.value = (question.rangeMin+question.rangeMax)/2;
4634

4735
el.style.marginBottom = "50px";
4836
var slider = noUiSlider.create(el, {
49-
start: startValue,
50-
connect: true,
37+
start: question.value,
38+
connect: [true, false],
39+
step: question.step,
40+
tooltips: true,
5141
pips: {
52-
mode: "steps",
53-
stepped: true,
54-
density: 4
42+
mode: "positions",
43+
values: [0,25,50,75,100],
44+
density: 5
5545
},
5646
range: {
5747
min: question.rangeMin,

0 commit comments

Comments
 (0)