-
Notifications
You must be signed in to change notification settings - Fork 159
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
elementui有关于popper,下拉错位 #55
Comments
据了解,elementUI 等使用的是 floating-ui / popper.js 插件 实现的弹出层,但是popper.js在计算弹出元素位置时,没有考虑页面整体缩放偏移的情况,所以在autofit.js的缩放方案中,会出现偏移错位的问题,目前autofit.js有计划使用其他方式解决偏移,但近期还没有好的方案,你可以尝试去floating-ui提个issue。 |
哪个ui支持的下拉框和弹框适配这个 @LarryZhu-dev |
@zhengdechang 目前已知国内主流组件库都不支持autofit.js |
有没有react的呢 |
@zhengdechang 我这暂时没发现呢 |
antd作为国内比较热门的组件库,能否抽空做一下适配呢,大佬。
|
这个我这边解决不了哈,需要antd去做适配呢 |
getPopupContainer 挂载一下 |
elementUI 有办法处理吗 |
目前,有弹出的,就跑错位了,是一个问题 |
Naive UI也会出现这个问题 |
实测[email protected]已解决,贴出方案供大家参考: 在 // 修复使用autofit.js导致的popover错位问题
// 这里的body对应的是autofit.init({el: 'body'})
const targetEl = document.querySelector('body')
const scaleMatch = targetEl.style.getPropertyValue('transform').match(/scale\((.*?)\)/)
// 获取缩放比例
const scale = scaleMatch ? +scaleMatch[1] : 1
Object.keys(referenceOffsets).forEach((key) => {
referenceOffsets[key] = referenceOffsets[key] / scale
}) 刷新页面,元素位置已经是正确的了 因为直接改的源码,需要使用 其他版本不知道代码位置会不会变,可以自己找找,应该变化不大。贴个图: 再来记录一下。后来发现在弹框比较贴边时定位还是不对,又经过一番排查,原来是还有一处没改: // 修复使用autofit.js导致的popover错位问题
// 这里的body对应的是autofit.init({el: 'body'})
const targetEl = document.querySelector('body')
const scaleMatch = targetEl.style.getPropertyValue('transform').match(/scale\((.*?)\)/)
// 获取缩放比例
const scale = scaleMatch ? +scaleMatch[1] : 1
Object.keys(boundaries).forEach((key) => {
boundaries[key] = boundaries[key] / scale
}) 目前看应该没问题了 |
楼上老哥的方案实测可用 版本 2.5.13 |
感谢诸位大佬[email protected]实测可用 |
使用 ignore 传入子串匹配选择器可解决弹出层偏移问题,在 element-plus 中,有一个id为el-popper-container-xxx的元素,将其传入 ignore 即可,对于 element-ui ,需要将弹出元素挂载到 body 根节点,或其他任何不在 autofit 影响下的节点即可,如 element 弹出层挂载到 |
No description provided.
The text was updated successfully, but these errors were encountered: