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

[Popup] Popup的显示目标位置变化时不能自动重新定位 #63

Open
jinzhubaofu opened this issue May 21, 2015 · 3 comments
Open

Comments

@jinzhubaofu
Copy link
Contributor

如何复现:

  1. 假设,target在正常文档流,相对于body的offsetTop是500px,此时Popup已经显示出来
  2. 接下来,把target之前的内容清空,这时target的offsetTop就会变成0
  3. 这时候Popup还停留在原地

这个问题的原因在于Popup的main元素直接挂载在body上。目前使用了Popup的组件都有这个问题。

我想到了两个办法

  1. 把popup挂载到组件的main元素内部。这个方案伤筋动骨,动作太大。
  2. 给body模拟一个offsetHeightChange的事件,性能上可能有问题

大家看看有什么好办法 @wuhy @michaelliu90316

@liulangyu90316
Copy link

之前在业务里面碰到过这个问题,采取的是外部再调用一下locate,重新定位
除了target变化会造成这个问题之外,tip的content变化也会引起这个问题,譬如方位为tl时

我觉得要是在组件内部来实现这个功能的话,成本颇大

在 2015年5月21日 下午12:18,leon notifications@github.com写道:

如何复现:

  1. 假设,target在正常文档流,相对于body的offsetTop是500px,此时Popup已经显示出来
  2. 接下来,把target之前的内容清空,这时target的offsetTop就会变成0
  3. 这时候Popup还停留在原地

这个问题的原因在于Popup的main元素直接挂载在body上。目前使用了Popup的组件都有这个问题。

我想到了两个办法

  1. 把popup挂载到组件的main元素内部。这个方案伤筋动骨,动作太大。
  2. 给body模拟一个offsetHeightChange的事件,性能上可能有问题

大家看看有什么好办法 @wuhy https://github.com/wuhy @michaelliu90316
https://github.com/michaelliu90316


Reply to this email directly or view it on GitHub
#63.

@jinzhubaofu
Copy link
Contributor Author

也许我们可以提供一个静态的方法,可以让用户手动地重新定位Popup的位置。比如:

var Popup = require('moye/Popup');

Popup.relocation();

这样应该是简单地很多的。

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

3 participants
@jinzhubaofu @liulangyu90316 and others