修正角度输入框的锁定图标和输入框位置错误的问题,修正用户Tab后输入一样的数值后锁定丢失的问题.

pull/111/head
ChenX 6 years ago
parent e1d3a5a2a9
commit b14aec1269

@ -25,10 +25,12 @@ export class AngleDynamicInput extends RealDynamicInput
super.Fixed = v;
this.angleSymbolEl.style.position = v ? "fixed" : "";
}
protected fixNumebr = 0;
set Value(v: number)
{
super.Value = v * 180 / Math.PI;
this.OnInput();
super.Value = Math.round(v * 180 / Math.PI);
this.UpdateSymbolElPosition();
}
get Value(): number
{

@ -14,9 +14,14 @@ export class DynamicInput
//创建的新输入框
inputEl: HTMLInputElement;
lockEl: HTMLElement;
//包装自身的容器.
container: HTMLElement;
UpdateWidth: Function;
constructor(container: HTMLElement)
{
this.container = document.createElement("div");
this.container.style.display = "inline-block";
this.lockEl = document.createElement("span");
this.lockEl.className = "bp3-icon-standard bp3-icon-lock";
this.lockEl.style.border = "3px solid #999";
@ -24,19 +29,17 @@ export class DynamicInput
this.lockEl.style.lineHeight = "inherit";
this.lockEl.style.height = "25px";
this.lockEl.style.display = "none";
container.appendChild(this.lockEl);
this.container.appendChild(this.lockEl);
this.inputEl = document.createElement('input');
this.inputEl.style.pointerEvents = "none";
this.inputEl.style.minWidth = "15px";
this.inputEl.addEventListener("input", () => { this.OnInput() });
this.inputEl.addEventListener("keydown", e => { this.OnInputKeyDown(e) });
this.inputEl.addEventListener("change", () =>
{
this.Lock = true;
});
this.inputEl.addEventListener("change", () => { this.Lock = true; });
this.inputEl.style.border = "3px solid transparent";
container.appendChild(this.inputEl);
this.container.appendChild(this.inputEl);
container.appendChild(this.container);
this.UpdateWidth = AutoReSize(this.inputEl).updateWidth;
this.Blur();
}
@ -115,6 +118,10 @@ export class DynamicInput
this.inputEl.style.backgroundColor = '#999';
DynamicInputManage.GetManage().IsInputing = false;
//当用户输入一样的数值时,不会触发Change事件,如果没触发,那么就没有hasLock.
if (this.inputEl.selectionEnd - this.inputEl.selectionStart === 0)
return;
if (this.m_HasLock) this.m_HasLock = false;
else this.Lock = false;
}
@ -122,17 +129,17 @@ export class DynamicInput
SetPosition(x, y)
{
if (DynamicInputManage.GetManage().IsInputing) return;
this.inputEl.style.left = x + "px";
this.inputEl.style.top = y + "px";
this.container.style.left = `${x}px`;
this.container.style.top = `${y}px`;
}
//设置对象的定位方式 true为绝对定位,false 时为相对定位
set Fixed(v: boolean)
{
this.inputEl.style.position = v ? "fixed" : "";
this.container.style.position = v ? "fixed" : "";
}
//销毁.
Destroy()
{
this.inputEl.remove();
this.container.remove();
}
}

@ -10,10 +10,11 @@ export class RealDynamicInput extends DynamicInput
super(container);
this.Value = 0;
}
protected fixNumebr = 4;
set Value(v: number)
{
super.Value = v.toFixed(4);
this.UpdateWidth();
super.Value = v.toFixed(this.fixNumebr);
}
//返回一个计算完成的实数结果.
get Value(): number

Loading…
Cancel
Save