Move clamp to function
parent
04ebf76e16
commit
4de923420a
|
|
@ -1,29 +1,27 @@
|
||||||
onUiLoaded(function() {
|
onUiLoaded(function() {
|
||||||
gradioApp().querySelector("#qrcode_geo_latitude input").addEventListener("input", (event) => {
|
gradioApp().querySelector("#qrcode_geo_latitude input").addEventListener("input", (event) => {
|
||||||
let target = event.originalTarget || event.composedPath()[0];
|
let target = event.originalTarget || event.composedPath()[0];
|
||||||
if (target.value < -90) {
|
let value = target.value;
|
||||||
target.value = -90;
|
if (value < -90 || value > 90) {
|
||||||
} else if (target.value > 90) {
|
target.value = clamp(value, -90, 90)
|
||||||
target.value = 90;
|
updateInput(target);
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
updateInput(target);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gradioApp().querySelector("#qrcode_geo_longitude input").addEventListener("input", (event) => {
|
gradioApp().querySelector("#qrcode_geo_longitude input").addEventListener("input", (event) => {
|
||||||
let target = event.originalTarget || event.composedPath()[0];
|
let target = event.originalTarget || event.composedPath()[0];
|
||||||
if (target.value < -180) {
|
let value = target.value;
|
||||||
target.value = -180;
|
if (value < -180 || value > 180) {
|
||||||
} else if (target.value > 180) {
|
target.value = clamp(value, -180, 180)
|
||||||
target.value = 180;
|
updateInput(target);
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
updateInput(target);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function clamp(num, min, max) {
|
||||||
|
return Math.min(Math.max(num, min), max);
|
||||||
|
};
|
||||||
|
|
||||||
async function sendToControlnet(img, tab, index) {
|
async function sendToControlnet(img, tab, index) {
|
||||||
const response = await fetch(img);
|
const response = await fetch(img);
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue