浏览代码

Preserve the world height when changing units, thus matching other inputs

tags/v0.1.0
Fen Dweller 6 年前
父节点
当前提交
aad8c4e7f2
共有 1 个文件被更改,包括 19 次插入13 次删除
  1. +19
    -13
      macrovision.js

+ 19
- 13
macrovision.js 查看文件

@@ -1434,6 +1434,14 @@ document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#help").classList.remove("visible");
});

document.querySelector("#options-height-value").addEventListener("change", e => {
updateWorldHeight();
})

document.querySelector("#options-height-value").addEventListener("keydown", e => {
e.stopPropagation();
})

const unitSelector = document.querySelector("#options-height-unit");

unitChoices.length.forEach(lengthOption => {
@@ -1449,6 +1457,17 @@ document.addEventListener("DOMContentLoaded", () => {
unitSelector.appendChild(option);
});

unitSelector.setAttribute("oldUnit", "meters");

unitSelector.addEventListener("input", e => {
checkFitWorld();
const scaleInput = document.querySelector("#options-height-value");
const newVal = math.unit(scaleInput.value, unitSelector.getAttribute("oldUnit")).toNumber(e.target.value);
setNumericInput(scaleInput, newVal);
updateWorldHeight();
unitSelector.setAttribute("oldUnit", unitSelector.value);
});

param = new URL(window.location.href).searchParams.get("scene");

if (param === null) {
@@ -1503,19 +1522,6 @@ document.addEventListener("DOMContentLoaded", () => {

updateSizes();

document.querySelector("#options-height-value").addEventListener("change", e => {
updateWorldHeight();
})

document.querySelector("#options-height-value").addEventListener("keydown", e => {
e.stopPropagation();
})

unitSelector.addEventListener("input", e => {
checkFitWorld();
updateWorldHeight();
})

world.addEventListener("mousedown", e => deselect());
document.querySelector("#entities").addEventListener("mousedown", deselect);
document.querySelector("#display").addEventListener("mousedown", deselect);


正在加载...
取消
保存