diff --git a/src/UI/Components/commandLineInput/InputHint.tsx b/src/UI/Components/commandLineInput/InputHint.tsx index fb90860ea..ff384d08b 100644 --- a/src/UI/Components/commandLineInput/InputHint.tsx +++ b/src/UI/Components/commandLineInput/InputHint.tsx @@ -21,7 +21,6 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is private m_box: HTMLElement;//移动命令框区 public state: ITodoItemState; private m_i: number = 0; //选择历史命令索引 - constructor(props) { super(props); @@ -42,7 +41,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is if (!m_inputValue) { - store.searchCommand.splice(0, store.searchCommand.length); + store.searchCommand.length = 0; return; } // 动态生成正则表达式 @@ -88,7 +87,6 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is store.Prompt(e.currentTarget.innerHTML); store.execCommand(e.currentTarget.innerHTML); - // store.searchCommand.splice(0, store.searchCommand.length); store.searchCommand.length = 0; } @@ -102,9 +100,9 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is //↑-38 ,↓-40 esc-27 if (e.keyCode === 27) //按esc键,清空所有命令 { - searchCommand.splice(0, searchCommand.length); + searchCommand.length = 0; - viceCommand.splice(0, viceCommand.length); + viceCommand.length = 0; this.setState( { @@ -198,7 +196,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is if (this.state.command && CommandList.indexOf(this.state.command.trim()) !== -1) { - searchCommand.splice(0, searchCommand.length); + searchCommand.length = 0; } else @@ -212,7 +210,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is if (this.state.command === 'U') { - viceCommand.splice(0, viceCommand.length); + viceCommand.length = 0; return; } viceCommand.push({ title: '放弃', keyboard: 'U' }) @@ -229,7 +227,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is let m_key = e.currentTarget.firstElementChild.innerHTML.slice(1, 2); if (m_key === 'U') { - viceCommand.splice(0, viceCommand.length); + viceCommand.length = 0; } } //鼠标选择命令 @@ -243,22 +241,6 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore, is } (e.target as HTMLElement).className = 'hover'; } - //获取元素到屏幕的距离 - public handleGetElHeight = (el: HTMLElement) => - { - let m_actualTop: number = el.offsetTop; //元素离顶部高度 - let m_current = el.offsetParent; - - while (m_current !== null) - { - m_actualTop += (m_current as HTMLElement).offsetTop; - m_current = (m_current as HTMLElement).offsetParent; - } - let m_actualBottom: number = window.innerHeight - m_actualTop - el.clientHeight;//元素离底部高度 - - let m_outPutDes = { m_actualTop, m_actualBottom };//输出距离对象 - return m_outPutDes; - } componentDidMount() { document.body.addEventListener('keydown', this.handleSelectCommand);