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

event.delegate(document.body)对于mip-fixed元素失效 #80

Closed
jennyliang220 opened this issue Jul 24, 2018 · 1 comment
Closed

event.delegate(document.body)对于mip-fixed元素失效 #80

jennyliang220 opened this issue Jul 24, 2018 · 1 comment
Assignees
Labels
bug Something isn't working P0

Comments

@jennyliang220
Copy link
Member

jennyliang220 commented Jul 24, 2018

问题描述

let event = window.MIP.util.event
let me = this

this.jumpHandler = event.delegate(document.body, '[mip-link]', 'click', function (e) {
  me._closeEverything() // 当页面出现跳转时,关闭所有的浮层
})

代码如上,但mip-fixed元素会被挪到第二个body里面,导致mip-fixed元素中的事件代理失效。

测试连接:

预期效果:点击页面出现弹层,点击弹层【下一页】链接时翻页且弹层收起
image

iframe+mip-fixed,存在两个body,点击有问题:https://www.mipengine.org/validator/preview/mip?title=MIP%20%E9%A2%84%E8%A7%88&ext=%7B%22url%22%3A%22https%3A%2F%2Fdeploy-preview-129--mip2-deploy-preview.netlify.com%2Fexamples%2Fmip-shell-xiaoshuo%2Fmipx-xiaoshuo-1.html%22%7D

无iframe,不存在两个body,点击效果OK: https://deploy-preview-129--mip2-deploy-preview.netlify.com/examples/mip-shell-xiaoshuo/mipx-xiaoshuo-1.html

@PengXing PengXing added bug Something isn't working P0 labels Jul 24, 2018
@jennyliang220
Copy link
Member Author

jennyliang220 commented Jul 24, 2018

想到了一个绕开的办法,比较挫,能解决问题。

// 不好使,因为代理到第一个body上面,第二个body没有delegate
event.delegate(document.body, ……)

// 代理到html根元素上,无论几个body,html只有一个!!!
event.delegate(document.documentElement, ……)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0
Projects
None yet
Development

No branches or pull requests

3 participants