Show LoRA model/CLIP dials at the 0.05 step instead of rounding to one decimal.

0.25 and 0.35 both looked like 0.3, so snofs strengths on stills did not match the wheels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-03 08:29:55 -05:00
co-authored by Cursor
parent 78b158471b
commit d7045c0a07
2 changed files with 23 additions and 8 deletions
+6
View File
@@ -56,6 +56,9 @@
:min="LORA_STRENGTH_MIN" :min="LORA_STRENGTH_MIN"
:max="LORA_STRENGTH_MAX" :max="LORA_STRENGTH_MAX"
:step="LORA_STRENGTH_STEP" :step="LORA_STRENGTH_STEP"
:fine-step="LORA_STRENGTH_STEP"
:coarse-step="0.25"
:digits="2"
compact compact
:disabled="disabled" :disabled="disabled"
@update:model-value="setStrength(index, 'strengthModel', $event)" @update:model-value="setStrength(index, 'strengthModel', $event)"
@@ -67,6 +70,9 @@
:min="LORA_STRENGTH_MIN" :min="LORA_STRENGTH_MIN"
:max="LORA_STRENGTH_MAX" :max="LORA_STRENGTH_MAX"
:step="LORA_STRENGTH_STEP" :step="LORA_STRENGTH_STEP"
:fine-step="LORA_STRENGTH_STEP"
:coarse-step="0.25"
:digits="2"
compact compact
:disabled="disabled || !clipStrength" :disabled="disabled || !clipStrength"
@update:model-value="setStrength(index, 'strengthClip', $event)" @update:model-value="setStrength(index, 'strengthClip', $event)"
+17 -8
View File
@@ -115,7 +115,6 @@ const props = withDefaults(defineProps<{
dragRange?: number dragRange?: number
}>(), { }>(), {
step: 0.1, step: 0.1,
fineStep: 0.1,
coarseStep: 1, coarseStep: 1,
label: '', label: '',
ariaLabel: '', ariaLabel: '',
@@ -142,10 +141,21 @@ const storeKey = computed(() => {
}) })
const frozen = computed(() => props.disabled || locked.value) const frozen = computed(() => props.disabled || locked.value)
const span = computed(() => Math.max(props.max - props.min, 0.0001)) const span = computed(() => Math.max(props.max - props.min, 0.0001))
const tick = computed(() => props.step || 0.1)
const fine = computed(() => (Number.isFinite(props.fineStep) && Number(props.fineStep) > 0 ? Number(props.fineStep) : tick.value))
const places = computed(() => Math.max(props.digits, stepDecimalPlaces(tick.value)))
const pct = computed(() => ((clamp(model.value) - props.min) / span.value) * 100) const pct = computed(() => ((clamp(model.value) - props.min) / span.value) * 100)
const display = computed(() => format(model.value)) const display = computed(() => format(model.value))
const drumShift = computed(() => Math.round((pct.value / 100) * 72)) const drumShift = computed(() => Math.round((pct.value / 100) * 72))
function stepDecimalPlaces(step: number) {
if (!Number.isFinite(step) || step <= 0) return 1
if (step >= 1) return 0
const text = step.toFixed(8).replace(/0+$/, '')
const dot = text.indexOf('.')
return dot >= 0 ? text.length - dot - 1 : 0
}
function readLock() { function readLock() {
if (!storeKey.value || typeof localStorage === 'undefined') return if (!storeKey.value || typeof localStorage === 'undefined') return
try { try {
@@ -165,17 +175,16 @@ function toggleLock() {
function clamp(value: number) { function clamp(value: number) {
if (!Number.isFinite(value)) return props.min if (!Number.isFinite(value)) return props.min
const step = props.step || 0.1 const step = tick.value
const snapped = Math.round(value / step) * step const snapped = Math.round(value / step) * step
const places = step < 0.1 ? 2 : 1 const rounded = Number(snapped.toFixed(places.value))
const rounded = Number(snapped.toFixed(places))
return Math.min(props.max, Math.max(props.min, rounded)) return Math.min(props.max, Math.max(props.min, rounded))
} }
function format(value: number) { function format(value: number) {
const n = clamp(value) const n = clamp(value)
if (props.digits === 0) return String(Math.round(n)) if (places.value <= 0) return String(Math.round(n))
return n.toFixed(props.digits).replace(/\.0+$/, '').replace(/(\.\d*[1-9])0+$/, '$1') return n.toFixed(places.value).replace(/\.0+$/, '').replace(/(\.\d*[1-9])0+$/, '$1')
} }
function nudge(delta: number) { function nudge(delta: number) {
@@ -185,13 +194,13 @@ function nudge(delta: number) {
function onWheel(event: WheelEvent) { function onWheel(event: WheelEvent) {
if (frozen.value) return if (frozen.value) return
event.preventDefault() event.preventDefault()
const step = event.shiftKey ? props.coarseStep : props.fineStep const step = event.shiftKey ? props.coarseStep : fine.value
nudge(event.deltaY < 0 ? step : -step) nudge(event.deltaY < 0 ? step : -step)
} }
function onKey(event: KeyboardEvent) { function onKey(event: KeyboardEvent) {
if (frozen.value) return if (frozen.value) return
const step = event.shiftKey ? props.coarseStep : props.fineStep const step = event.shiftKey ? props.coarseStep : fine.value
if (event.key === 'ArrowUp' || event.key === 'ArrowRight') { if (event.key === 'ArrowUp' || event.key === 'ArrowRight') {
event.preventDefault() event.preventDefault()
nudge(step) nudge(step)