aceEditor 这段代码的作用?

如题,我在模态框里面使用editor的时候,第一次聚焦会导致模态框重新定位,若果模态框里包含滚动条,会导致重新回到顶部。debug之后发现是这一段代码导致的。问题是我不太明白他这么写的作用是什么?求大神解答

附上源码地址

this.focus = function() {
    if (tempStyle) return text.focus();
    var top = text.style.top;
    text.style.position = "fixed"
    text.style.top = "-1000px";
    text.focus();
    setTimeout(function() {
        text.style.position = "";
        if (text.style.top == "-1000px")                                
            text.style.top = top;
    }, 0);
};
阅读 1.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题