Skip to content

Commit 0a91fe6

Browse files
ujimushipiever
andauthored
add 'direction' kwargs to rangeslider (#174) (#175)
* add 'direction' kwargs to rangeslider * Fix docstring Co-authored-by: Pietro Vertechi <[email protected]> * function signature updated --------- Co-authored-by: Pietro Vertechi <[email protected]>
1 parent 564eebc commit 0a91fe6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/slider.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,27 @@ end
7474
```
7575
function rangeslider(vals::AbstractArray;
7676
value=medianelement(vals),
77-
label=nothing, readout=true, kwargs...)
77+
label=nothing, readout=true,
78+
orientation="horizontal",
79+
direction="ltr", kwargs...)
7880
```
7981
8082
Creates a slider widget which can take on the values in `vals` and accepts several "handles".
8183
Pass a vector to `value` with two values if you want to select a range.
84+
Use the `orientation="vertical"` keyword argument to create a vertical slider.
85+
By default the slider is top-to-botom and left-to-right,
86+
but this can be changed using the `direction="rtl"` keyword argument.
8287
"""
8388
function rangeslider(theme::WidgetTheme, vals::AbstractUnitRange{<:Integer}, formatted_vals = format.(vals);
8489
style = Dict(), label = nothing, value = medianelement(vals), orientation = "horizontal", readout = true,
85-
className = "is-primary")
90+
className = "is-primary", direction="ltr")
8691

8792
T = Observables.to_value(value) isa Vector ? Vector{eltype(vals)} : eltype(vals)
8893
value isa AbstractObservable || (value = Observable{T}(value))
8994

9095
index = value
9196
orientation = string(orientation)
97+
direction = string(direction)
9298
preprocess = T<:Vector ? js"unencoded.map(Math.round)" : js"Math.round(unencoded[0])"
9399

94100
scp = Scope(imports = vcat([nouislider_min_js, nouislider_min_css], libraries(theme)))
@@ -122,6 +128,7 @@ function rangeslider(theme::WidgetTheme, vals::AbstractUnitRange{<:Integer}, for
122128
tooltips: $tooltips,
123129
connect: $connect,
124130
orientation: $orientation,
131+
direction: $direction,
125132
format: {
126133
to: function ( value ) {
127134
var ind = Math.round(value-($min));

0 commit comments

Comments
 (0)