fix(dual-range-slider): allow equal min/max values in Lora Randomizer (#775)

Add allowEqualValues prop to DualRangeSlider component (default: false for backward compatibility).
When enabled, removes the step offset constraint that prevented min and max handles from being set to the same value.

Applied to all range sliders in LoraRandomizerSettingsView:
- LoRA Count range slider
- Model Strength Range slider
- Recommended Strength Scale slider
- Clip Strength Range slider

Backend already handles equal values correctly via rng.uniform().
This commit is contained in:
Will Miao
2026-01-22 16:47:39 +08:00
parent 6fbea77137
commit d1c65a6186
4 changed files with 82 additions and 71 deletions

View File

@@ -48,6 +48,7 @@
:value-max="countMax"
:step="1"
:default-range="{ min: 1, max: 5 }"
:allow-equal-values="true"
@update:value-min="$emit('update:countMin', $event)"
@update:value-max="$emit('update:countMax', $event)"
/>
@@ -67,6 +68,7 @@
:default-range="{ min: -2, max: 3 }"
:scale-mode="'segmented'"
:segments="strengthSegments"
:allow-equal-values="true"
@update:value-min="$emit('update:modelStrengthMin', $event)"
@update:value-max="$emit('update:modelStrengthMax', $event)"
/>
@@ -101,6 +103,7 @@
:step="0.1"
:default-range="{ min: 0.5, max: 1.0 }"
:disabled="!useRecommendedStrength"
:allow-equal-values="true"
@update:value-min="$emit('update:recommendedStrengthScaleMin', $event)"
@update:value-max="$emit('update:recommendedStrengthScaleMax', $event)"
/>
@@ -137,6 +140,7 @@
:scale-mode="'segmented'"
:segments="strengthSegments"
:disabled="isClipStrengthDisabled"
:allow-equal-values="true"
@update:value-min="$emit('update:clipStrengthMin', $event)"
@update:value-max="$emit('update:clipStrengthMax', $event)"
/>

View File

@@ -83,10 +83,12 @@ const props = withDefaults(defineProps<{
disabled?: boolean
scaleMode?: ScaleMode
segments?: Segment[]
allowEqualValues?: boolean
}>(), {
disabled: false,
scaleMode: 'linear',
segments: () => []
segments: () => [],
allowEqualValues: false
})
const emit = defineEmits<{
@@ -242,12 +244,12 @@ const updateValue = (event: PointerEvent) => {
if (dragging.value === 'min') {
const maxMultiplier = getSegmentStepMultiplier(props.valueMax)
const maxAllowed = props.valueMax - (props.step * maxMultiplier)
const maxAllowed = props.allowEqualValues ? props.valueMax : props.valueMax - (props.step * maxMultiplier)
const newValue = Math.min(value, maxAllowed)
emit('update:valueMin', newValue)
} else {
const minMultiplier = getSegmentStepMultiplier(props.valueMin)
const minAllowed = props.valueMin + (props.step * minMultiplier)
const minAllowed = props.allowEqualValues ? props.valueMin : props.valueMin + (props.step * minMultiplier)
const newValue = Math.max(value, minAllowed)
emit('update:valueMax', newValue)
}
@@ -290,14 +292,14 @@ const onWheel = (event: WheelEvent) => {
const effectiveStep = props.step * multiplier
const newValue = snapToStep(props.valueMin + delta * effectiveStep, multiplier)
const maxMultiplier = getSegmentStepMultiplier(props.valueMax)
const maxAllowed = props.valueMax - (props.step * maxMultiplier)
const maxAllowed = props.allowEqualValues ? props.valueMax : props.valueMax - (props.step * maxMultiplier)
emit('update:valueMin', Math.min(newValue, maxAllowed))
} else if (relativeX > maxPixel) {
const multiplier = getSegmentStepMultiplier(props.valueMax)
const effectiveStep = props.step * multiplier
const newValue = snapToStep(props.valueMax + delta * effectiveStep, multiplier)
const minMultiplier = getSegmentStepMultiplier(props.valueMin)
const minAllowed = props.valueMin + (props.step * minMultiplier)
const minAllowed = props.allowEqualValues ? props.valueMin : props.valueMin + (props.step * minMultiplier)
emit('update:valueMax', Math.max(newValue, minAllowed))
} else {
const minMultiplier = getSegmentStepMultiplier(props.valueMin)
@@ -309,8 +311,8 @@ const onWheel = (event: WheelEvent) => {
emit('update:valueMin', Math.max(newMin, props.min))
emit('update:valueMax', Math.min(newMax, props.max))
} else {
const minAllowed = props.valueMin + (props.step * minMultiplier)
if (newMin < newMax - (props.step * minMultiplier)) {
const maxAllowed = props.allowEqualValues ? newMax : newMax - (props.step * minMultiplier)
if (newMin <= maxAllowed) {
emit('update:valueMin', newMin)
emit('update:valueMax', newMax)
}