From 401fc30617302c347ad5dba1413a212d55bdd0e4 Mon Sep 17 00:00:00 2001 From: Olivia Godone-Maresca Date: Sat, 3 Jun 2023 14:54:17 -0400 Subject: [PATCH] Allow LoRA strengths between -2 and 2 --- ui/index.html | 2 +- ui/media/js/main.js | 8 ++++---- ui/media/js/utils.js | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/index.html b/ui/index.html index 88917b68..6cc6978c 100644 --- a/ui/index.html +++ b/ui/index.html @@ -227,7 +227,7 @@ -
+
diff --git a/ui/media/js/main.js b/ui/media/js/main.js index ef27cf1b..e4043fa0 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1725,10 +1725,10 @@ function updateLoraAlpha() { } function updateLoraAlphaSlider() { - if (loraAlphaField.value < 0) { - loraAlphaField.value = 0 - } else if (loraAlphaField.value > 1) { - loraAlphaField.value = 1 + if (loraAlphaField.value < -2) { + loraAlphaField.value = -2 + } else if (loraAlphaField.value > 2) { + loraAlphaField.value = 2 } loraAlphaSlider.value = loraAlphaField.value * 100 diff --git a/ui/media/js/utils.js b/ui/media/js/utils.js index 6ddb0ae6..871ba714 100644 --- a/ui/media/js/utils.js +++ b/ui/media/js/utils.js @@ -402,12 +402,12 @@ function debounce(func, wait, immediate) { function preventNonNumericalInput(e) { e = e || window.event - let charCode = typeof e.which == "undefined" ? e.keyCode : e.which - let charStr = String.fromCharCode(charCode) - let re = e.target.getAttribute("pattern") || "^[0-9]+$" - re = new RegExp(re) + const charCode = typeof e.which == "undefined" ? e.keyCode : e.which + const charStr = String.fromCharCode(charCode) + const newInputValue = `${e.target.value}${charStr}` + const re = new RegExp(e.target.getAttribute("pattern") || "^[0-9]+$") - if (!charStr.match(re)) { + if (!re.test(charStr) && !re.test(newInputValue)) { e.preventDefault() } }