Index: sources/gui/qml/components/RangeSlider.qml =================================================================== diff -u -r27cc308ff5113a9386899d3c8f8b29962a8498e1 -rcd4b8fbd5ea88717e74dd4cbe00dac82d9844dde --- sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision 27cc308ff5113a9386899d3c8f8b29962a8498e1) +++ sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision cd4b8fbd5ea88717e74dd4cbe00dac82d9844dde) @@ -165,55 +165,57 @@ /// \param x : the active slider x cordinate. /// function setValue(x) { - var value = 0 - if ( x < 0 ) { value = minimum; return value; } - if ( x > width ) { value = maximum; return value; } + let mValue = 0 + if ( x < 0 ) { mValue = minimum; return mValue; } + if ( x > width ) { mValue = maximum; return mValue; } - value = getValueOfX(x) + mValue = getValueOfX(x) - if ( step === 1 ) { return value; } + if ( step === 1 ) { return mValue; } - var start = 0 + let start = 0 if ( ! stepSnap ) start = minimum + mValue = Math.round((mValue - start) / step) * step + start - value = Math.round((value - start) / step) * step + start + let decimals = Math.round(-Math.log10(step)) + if (decimals > 0) mValue = mValue.toFixed(decimals) - if ( value < minimum ) { value = minimum; return value; } - if ( value > maximum ) { value = maximum; return value; } - return value; + if ( mValue < minimum ) { mValue = minimum; return mValue; } + if ( mValue > maximum ) { mValue = maximum; return mValue; } + return mValue; } /// /// \brief updates correct lower or upper bound value regarding the x position /// \details regarding the current mouse x position selects the correct handler and updated the bound value. /// \param x : mouse x position. function setBound(x) { - var value = setValue(x) + let mValue = setValue(x) // console.debug( maxValue - minValue, minValue, value, maxValue ) if ( maxValue - minValue <= gapValue ) { // max correction if the values get too close together less than defined gap if ( curHandler === RangeSlider.HandlerOption.Max ) maxValue = minValue + gapValue // min correction if the values get too close together less than defined gap if ( curHandler === RangeSlider.HandlerOption.Min ) minValue = maxValue - gapValue // while value is between min and max do nothing and let the value gets out of the bound and then apply value. - if ( minValue <= value && value <= maxValue ) return + if ( minValue <= mValue && mValue <= maxValue ) return } - var minDiff = Math.abs(minValue - value) - var maxDiff = Math.abs(maxValue - value) + let minDiff = Math.abs(minValue - mValue) + let maxDiff = Math.abs(maxValue - mValue) if ( minDiff === maxDiff ) { - if ( curHandler === RangeSlider.HandlerOption.Max ) checkLimitsMaxValueBounds(value) - else checkLimitsMinValueBounds(value) + if ( curHandler === RangeSlider.HandlerOption.Max ) checkLimitsMaxValueBounds(mValue) + else checkLimitsMinValueBounds(mValue) } else { // console.debug( minDiff, minValue, value, maxValue, maxDiff ) if ( minDiff < maxDiff ) { // if (minDiff > limitGap) return // not sure if it needs but kept it as an idea. - checkLimitsMinValueBounds(value) + checkLimitsMinValueBounds(mValue) } else { // if (maxDiff > limitGap) return // not sure if it needs but kept it as an idea. - checkLimitsMaxValueBounds(value) + checkLimitsMaxValueBounds(mValue) } } }