@@ -42,20 +42,21 @@ function slider(vals::AbstractArray;
42
42
Creates a slider widget which can take on the values in `vals`, and updates
43
43
observable `value` when the slider is changed.
44
44
"""
45
- function slider (:: WidgetTheme , vals:: AbstractRange {<:Integer} , formatted_vals;
45
+ function slider (:: WidgetTheme , vals:: AbstractUnitRange {<:Integer} , formatted_vals = format .(vals) ;
46
46
className= getclass (:input , " range" , " fullwidth" ),
47
47
readout= true , label= nothing , value= medianelement (vals), orientation = " horizontal" , attributes = Dict (), kwargs... )
48
48
49
+ min, max = extrema (vals)
49
50
orientation = string (orientation)
50
51
attributes = merge (attributes, Dict (" orient" => orientation))
51
52
(value isa AbstractObservable) || (value = convert (eltype (vals), value))
52
53
format = js """
53
54
function (){
54
- return this .formatted_vals ()[parseInt (this .index ())- 1 ];
55
+ return this .formatted_vals ()[parseInt (this .index ())- $min ];
55
56
}
56
57
"""
57
58
ui = input (value; bindto= " index" , attributes= attributes, extra_obs = [" formatted_vals" => formatted_vals], computed = [" formatted_val" => format],
58
- typ= " range" , min= minimum (vals) , max= maximum (vals) , step= step (vals) , className= className, kwargs... )
59
+ typ= " range" , min= min , max= max , step= 1 , className= className, kwargs... )
59
60
if (label != nothing ) || readout
60
61
if orientation != " vertical"
61
62
Widgets. scope (ui). dom = readout ?
@@ -79,7 +80,7 @@ function rangeslider(vals::AbstractArray;
79
80
Creates a slider widget which can take on the values in `vals` and accepts several "handles".
80
81
Pass a vector to `value` with two values if you want to select a range.
81
82
"""
82
- function rangeslider (theme:: WidgetTheme , vals:: AbstractRange {<:Integer} , formatted_vals = format .(vals);
83
+ function rangeslider (theme:: WidgetTheme , vals:: AbstractUnitRange {<:Integer} , formatted_vals = format .(vals);
83
84
style = Dict (), label = nothing , value = medianelement (vals), orientation = " horizontal" , readout = true ,
84
85
className = " is-primary" )
85
86
@@ -117,13 +118,13 @@ function rangeslider(theme::WidgetTheme, vals::AbstractRange{<:Integer}, formatt
117
118
var slider = document .getElementById ($id);
118
119
noUiSlider .create (slider, {
119
120
start: $start,
120
- step: $s ,
121
+ step: 1 ,
121
122
tooltips: $tooltips,
122
123
connect: $connect,
123
124
orientation: $orientation,
124
125
format: {
125
126
to : function ( value ) {
126
- var ind = Math .round (( value- $min) / $s );
127
+ var ind = Math .round (value- $min);
127
128
return ind + 1 > vals .length ? vals[vals .length - 1 ] : vals[ind];
128
129
},
129
130
from : function ( value ) {
0 commit comments