From 780ca2629cb6310107e10f4b30c709f157c1b28c Mon Sep 17 00:00:00 2001 From: ujimushi <10514830+ujimushi@users.noreply.github.com> Date: Tue, 14 Mar 2023 11:51:36 +0900 Subject: [PATCH 1/3] add 'direction' kwargs to rangeslider --- src/slider.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slider.jl b/src/slider.jl index dbc44c2..ff65c29 100644 --- a/src/slider.jl +++ b/src/slider.jl @@ -79,16 +79,20 @@ function rangeslider(vals::AbstractArray; Creates a slider widget which can take on the values in `vals` and accepts several "handles". Pass a vector to `value` with two values if you want to select a range. +Using the `orientation="vertical"` in kwargs, the slider is vertical. +By default the slider is top-to-botom and left-to-right, +but this can be changed using the `direction="rtl"` in kwargs. """ function rangeslider(theme::WidgetTheme, vals::AbstractUnitRange{<:Integer}, formatted_vals = format.(vals); style = Dict(), label = nothing, value = medianelement(vals), orientation = "horizontal", readout = true, - className = "is-primary") + className = "is-primary", direction="ltr") T = Observables.to_value(value) isa Vector ? Vector{eltype(vals)} : eltype(vals) value isa AbstractObservable || (value = Observable{T}(value)) index = value orientation = string(orientation) + direction = string(direction) preprocess = T<:Vector ? js"unencoded.map(Math.round)" : js"Math.round(unencoded[0])" scp = Scope(imports = vcat([nouislider_min_js, nouislider_min_css], libraries(theme))) @@ -122,6 +126,7 @@ function rangeslider(theme::WidgetTheme, vals::AbstractUnitRange{<:Integer}, for tooltips: $tooltips, connect: $connect, orientation: $orientation, + direction: $direction, format: { to: function ( value ) { var ind = Math.round(value-($min)); From d63d0c83c57329355903acc16e6bb1bb66d85fc7 Mon Sep 17 00:00:00 2001 From: ujimushi at Slashdot Japan <10514830+ujimushi@users.noreply.github.com> Date: Sat, 18 Mar 2023 13:21:35 +0900 Subject: [PATCH 2/3] Fix docstring Co-authored-by: Pietro Vertechi --- src/slider.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slider.jl b/src/slider.jl index ff65c29..020747e 100644 --- a/src/slider.jl +++ b/src/slider.jl @@ -79,9 +79,9 @@ function rangeslider(vals::AbstractArray; Creates a slider widget which can take on the values in `vals` and accepts several "handles". Pass a vector to `value` with two values if you want to select a range. -Using the `orientation="vertical"` in kwargs, the slider is vertical. +Use the `orientation="vertical"` keyword argument to create a vertical slider. By default the slider is top-to-botom and left-to-right, -but this can be changed using the `direction="rtl"` in kwargs. +but this can be changed using the `direction="rtl"` keyword argument. """ function rangeslider(theme::WidgetTheme, vals::AbstractUnitRange{<:Integer}, formatted_vals = format.(vals); style = Dict(), label = nothing, value = medianelement(vals), orientation = "horizontal", readout = true, From 4da4160a35cd06eee36312a8db6782524d4346c6 Mon Sep 17 00:00:00 2001 From: ujimushi <10514830+ujimushi@users.noreply.github.com> Date: Sat, 18 Mar 2023 13:48:44 +0900 Subject: [PATCH 3/3] function signature updated --- src/slider.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/slider.jl b/src/slider.jl index 020747e..385b8ed 100644 --- a/src/slider.jl +++ b/src/slider.jl @@ -74,7 +74,9 @@ end ``` function rangeslider(vals::AbstractArray; value=medianelement(vals), - label=nothing, readout=true, kwargs...) + label=nothing, readout=true, + orientation="horizontal", + direction="ltr", kwargs...) ``` Creates a slider widget which can take on the values in `vals` and accepts several "handles".