Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

弹出菜单位置不对 #9

Open
jiawen-Bees360 opened this issue Apr 9, 2018 · 2 comments
Open

弹出菜单位置不对 #9

jiawen-Bees360 opened this issue Apr 9, 2018 · 2 comments

Comments

@jiawen-Bees360
Copy link

感谢你的工作,但我发现有一点小问题,注意下方你的源码:你根据右键事件的clientX和clientY来直接设置menu的style的left和top,但是在一些布局中仅仅设置left和top根本无效,于是menu自始至终都会在文档流中的位置(而不是根据右键点击的位置改变)

    // 右键事件事件处理
    contextMenuHandler (e) {
      this.x = e.clientX
      this.y = e.clientY
      this.layout()
      this.$emit('update:show', true)
      e.preventDefault()
    },
    // 布局
    layout () {
      this.style = {
        left: this.x + 'px',
        top: this.y + 'px'
      }
    }

我加了一个position: absolute;,解决了我这边的问题,但不知道在别的布局方式中会不会有偏移。

@binggg
Copy link
Contributor

binggg commented Apr 9, 2018

好的,谢谢你的反馈,我会测试下不同的布局方式

@jiawen-Bees360
Copy link
Author

@binggg 我知道了,你的demo能work的原因在于你给组件加了一个.right-menu的class, 其中有position: fixed,或许可以把这个直接加到源码里面去。

.right-menu {
  position: fixed;
  background: #fff;
  border: solid 1px rgba(0, 0, 0, .2);
  border-radius: 3px;
  z-index: 999;
  display: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants