slider: prevent issues with decimal keys

This commit is contained in:
jean-emmanuel 2023-01-03 09:03:12 +01:00
parent fe9e988d3e
commit 1070ccb812
2 changed files with 3 additions and 2 deletions

View file

@ -22,14 +22,14 @@ class Slider extends Canvas {
this.rangeKeys = Object.keys(this.getProp('range')).sort((a,b)=>{
if (a === 'min' || b === 'max') return -1
else if (a === 'max' || b === 'min') return 1
else return parseInt(a) - parseInt(b)
else return parseFloat(a) - parseFloat(b)
})
this.rangeVals = []
this.rangeLabels = []
for (var i in this.rangeKeys) {
var k = this.rangeKeys[i],
key = k == 'min' ? 0 : k == 'max' ? 100 : parseInt(k),
key = k == 'min' ? 0 : k == 'max' ? 100 : parseFloat(k),
val = typeof this.getProp('range')[k] === 'object' && this.getProp('range')[k] !== null ?
this.getProp('range')[k][Object.keys(this.getProp('range')[k])[0]]:
this.getProp('range')[k]