Skip to content

Commit

Permalink
fix: #985 修复快捷键配置弹窗定位问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Nov 28, 2024
1 parent e509c9f commit 37e15c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/toolbars/ShortcutKeyConfigPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,14 @@ export default class ShortcutKeyConfigPanel {
throw new Error(`settingsDom must be an instance of HTMLElement, but got: ${settingsDom}`);
}
const pos = settingsDom.getBoundingClientRect();
const cherryWrapPos = this.$cherry.wrapperDom.getBoundingClientRect();
if (this.isHide()) {
this.dom.style.left = `${pos.left + pos.width / 2}px`;
this.dom.style.top = `${pos.top + pos.height}px`;
this.dom.style.left = `${pos.left - cherryWrapPos.left + pos.width / 2}px`;
this.dom.style.top = `${pos.top - cherryWrapPos.top + pos.height}px`;
this.show();
const me = this.dom.getBoundingClientRect();
this.dom.style.marginLeft = `0px`;
this.dom.style.left = `${pos.left + pos.width / 2 - me.width / 2}px`;
this.dom.style.left = `${pos.left - cherryWrapPos.left + pos.width / 2 - me.width / 2}px`;
// 如果弹窗位置超出屏幕,则自动调整位置
if (me.left + me.width > window.innerWidth) {
this.dom.style.left = `${window.innerWidth - me.width - 5}px`;
Expand Down

0 comments on commit 37e15c6

Please sign in to comment.