Selaa lähdekoodia

Avoid changing an option that was just set

Option fields were getting updated right after a value was entered, preventing more numbers
from being typed. Fields are now skipped if their change was what prompted an update.
tags/v0.0.1^0
Fen Dweller 5 vuotta sitten
vanhempi
commit
5fb453272a
1 muutettua tiedostoa jossa 12 lisäystä ja 9 poistoa
  1. +12
    -9
      macrovision.js

+ 12
- 9
macrovision.js Näytä tiedosto

@@ -422,14 +422,14 @@ function configViewOptions(entity, view) {
entity.views[view][key] = math.unit(input.value, select.value);
updateSizes();
updateEntityOptions(entity, view);
updateViewOptions(entity, view);
updateViewOptions(entity, view, key);
});

select.addEventListener("input", e => {
entity.views[view][key] = math.unit(input.value, select.value);
updateSizes();
updateEntityOptions(entity, view);
updateViewOptions(entity, view);
updateViewOptions(entity, view, key);
});

row.appendChild(input);
@@ -438,14 +438,17 @@ function configViewOptions(entity, view) {
}

function updateViewOptions(entity, view) {
function updateViewOptions(entity, view, changed) {
Object.entries(entity.views[view].attributes).forEach(([key, val]) => {
const input = document.querySelector("#options-view-" + key + "-input");
const select = document.querySelector("#options-view-" + key + "-select");
const currentUnit = select.value;
const convertedAmount = entity.views[view][key].to(currentUnit);
console.log(convertedAmount);
input.value = convertedAmount.value;
if (key != changed) {
const input = document.querySelector("#options-view-" + key + "-input");
const select = document.querySelector("#options-view-" + key + "-select");
const currentUnit = select.value;
const convertedAmount = entity.views[view][key].to(currentUnit);
console.log(convertedAmount);
input.value = math.round(convertedAmount.value, 5);
}
});
}



Loading…
Peruuta
Tallenna