Skip to content

Commit

Permalink
slider_ab onRangeInput flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst committed Sep 27, 2024
1 parent 59966fe commit 551eba6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/ui/elements/slider_ab.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ export default function slider_ab(params) {

// Check whether value is a number.
if (isNaN(value)) return false;

if (params.data_id === 'a' && value > maxInputParams.newValue) {

return false
}

if (params.data_id === 'b' && value < minInputParams.newValue) {

return false
}

if (params.min && value < params.min) {

// The value is smaller than min.
return false
}

if (params.max) {

return value <= params.max
}

return true
}

Expand Down Expand Up @@ -126,11 +126,11 @@ export default function slider_ab(params) {
max=${params.max}
step=${params.step}
value=${params.val_b}
oninput=${onRangeInput}/>`
oninput=${e => onRangeInput(e, params)}/>`

// The sliderElement property is required to update the range input on numeric input.
minInputParams.sliderElement = element
maxInputParams.sliderElement = element
minInputParams.sliderElement = element
maxInputParams.sliderElement = element

/**
@function onRangeInput
Expand All @@ -142,10 +142,11 @@ export default function slider_ab(params) {
@param {Object} e oninput event from range type input.
*/
function onRangeInput(e) {
function onRangeInput(e, params) {

// Range type input return a string target.value.
const val = Number(e.target.value)
params.onRangeInput = true;

// Check whether input event is from minRangeInput.
if (e.target.dataset.id === 'a') {
Expand Down

0 comments on commit 551eba6

Please sign in to comment.