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:
@@ -56,6 +56,9 @@
|
||||
:min="LORA_STRENGTH_MIN"
|
||||
:max="LORA_STRENGTH_MAX"
|
||||
:step="LORA_STRENGTH_STEP"
|
||||
:fine-step="LORA_STRENGTH_STEP"
|
||||
:coarse-step="0.25"
|
||||
:digits="2"
|
||||
compact
|
||||
:disabled="disabled"
|
||||
@update:model-value="setStrength(index, 'strengthModel', $event)"
|
||||
@@ -67,6 +70,9 @@
|
||||
:min="LORA_STRENGTH_MIN"
|
||||
:max="LORA_STRENGTH_MAX"
|
||||
:step="LORA_STRENGTH_STEP"
|
||||
:fine-step="LORA_STRENGTH_STEP"
|
||||
:coarse-step="0.25"
|
||||
:digits="2"
|
||||
compact
|
||||
:disabled="disabled || !clipStrength"
|
||||
@update:model-value="setStrength(index, 'strengthClip', $event)"
|
||||
|
||||
@@ -115,7 +115,6 @@ const props = withDefaults(defineProps<{
|
||||
dragRange?: number
|
||||
}>(), {
|
||||
step: 0.1,
|
||||
fineStep: 0.1,
|
||||
coarseStep: 1,
|
||||
label: '',
|
||||
ariaLabel: '',
|
||||
@@ -142,10 +141,21 @@ const storeKey = computed(() => {
|
||||
})
|
||||
const frozen = computed(() => props.disabled || locked.value)
|
||||
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 display = computed(() => format(model.value))
|
||||
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() {
|
||||
if (!storeKey.value || typeof localStorage === 'undefined') return
|
||||
try {
|
||||
@@ -165,17 +175,16 @@ function toggleLock() {
|
||||
|
||||
function clamp(value: number) {
|
||||
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 places = step < 0.1 ? 2 : 1
|
||||
const rounded = Number(snapped.toFixed(places))
|
||||
const rounded = Number(snapped.toFixed(places.value))
|
||||
return Math.min(props.max, Math.max(props.min, rounded))
|
||||
}
|
||||
|
||||
function format(value: number) {
|
||||
const n = clamp(value)
|
||||
if (props.digits === 0) return String(Math.round(n))
|
||||
return n.toFixed(props.digits).replace(/\.0+$/, '').replace(/(\.\d*[1-9])0+$/, '$1')
|
||||
if (places.value <= 0) return String(Math.round(n))
|
||||
return n.toFixed(places.value).replace(/\.0+$/, '').replace(/(\.\d*[1-9])0+$/, '$1')
|
||||
}
|
||||
|
||||
function nudge(delta: number) {
|
||||
@@ -185,13 +194,13 @@ function nudge(delta: number) {
|
||||
function onWheel(event: WheelEvent) {
|
||||
if (frozen.value) return
|
||||
event.preventDefault()
|
||||
const step = event.shiftKey ? props.coarseStep : props.fineStep
|
||||
const step = event.shiftKey ? props.coarseStep : fine.value
|
||||
nudge(event.deltaY < 0 ? step : -step)
|
||||
}
|
||||
|
||||
function onKey(event: KeyboardEvent) {
|
||||
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') {
|
||||
event.preventDefault()
|
||||
nudge(step)
|
||||
|
||||
Reference in New Issue
Block a user