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

Table 表格组件 头部 fixed 之后 表格body与header列错误(mac下正常,window下错位) #25300

Closed
1 task
howieyi opened this issue Jun 30, 2020 · 21 comments

Comments

@howieyi
Copy link

howieyi commented Jun 30, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

进入演示代码后,选择显示边框,选择固定头部,body 和 header 单元格会错位

What is expected?

window下,单元格正常无错位

What is actually happening?

window下单元格错位严重,甚至header引入单元格拖动宽度后,错位会更加严重,mac下正常

Environment Info
antd 4.0.0
React 16.12.0
System window
Browser chrome
@afc163
Copy link
Member

afc163 commented Jun 30, 2020

给个截图?

@howieyi
Copy link
Author

howieyi commented Jun 30, 2020

image

@zombieJ
Copy link
Member

zombieJ commented Jun 30, 2020

看你的按钮样式似乎缩放了屏幕?

@afc163
Copy link
Member

afc163 commented Jul 1, 2020

#25207

@afc163 afc163 closed this as completed Jul 1, 2020
@howieyi
Copy link
Author

howieyi commented Jul 1, 2020

没有缩放屏幕,正常打开就这样的

@zombieJ
Copy link
Member

zombieJ commented Jul 1, 2020

应该也是 windows 下高清屏设置了显示百分比

@howieyi
Copy link
Author

howieyi commented Jul 2, 2020

没有,我想说什么都没设置。。。就正常打开就这样了,你们试下window电脑都可以重现的,fixed header 之后就可以了。。。

@afc163
Copy link
Member

afc163 commented Jul 2, 2020

@howieyi 试一下 Ctrl + 0

@howieyi
Copy link
Author

howieyi commented Jul 2, 2020

额,已经说了浏览器没有做放大缩小。。。。别把别人当小白呀。。。我都说了几遍了,你们找一台window电脑试一下不就知道了,不要一直揣测。。。。

@afc163 afc163 reopened this Jul 2, 2020
@afc163
Copy link
Member

afc163 commented Jul 2, 2020

image

image

不只是 windows,列头和内容宽度在精度上确实会有一些差异。

@afc163

This comment has been minimized.

@zombieJ
Copy link
Member

zombieJ commented Jul 2, 2020

我们可能需要更精确的宽度监听 @zombieJ

https://github.com/react-component/resize-observer/blob/000b8dead14be42540057ed6b23a71ce7a84bb66/src/index.tsx#L87-L93

这端防抖代码,不参与计算。问题在于 offsetWidth 返回像素尺寸,而 getBoundingClientRect 会被外层的 transform 影响实际值。我试试用 getComputedStyle 来看看效果。

@zombieJ
Copy link
Member

zombieJ commented Jul 2, 2020

@howieyi @afc163

它不仅仅是游览器的缩放,在 windows 的高清屏下分辨率还有一层缩放:
mmexport1593694947156

这是我的 windows 下 100%:
mmexport1593694661885

@zombieJ
Copy link
Member

zombieJ commented Jul 2, 2020

另外试了一下 getComputedStyle 能获取精确像素,但是设置上去后没有效果。

@afc163
Copy link
Member

afc163 commented Jul 4, 2020

@howieyi 看看是不是上面说的操作系统里的缩放与布局打开了,如果也是这种情况我们可能没什么办法。

@howieyi
Copy link
Author

howieyi commented Jul 7, 2020

@afc163 的确这种情况可以,不过window10人家推荐都125%显示了,难道还要让人家用户自己去设置这个吗,不合理呀

@afc163
Copy link
Member

afc163 commented Jul 7, 2020

@howieyi 主要还是我们没有办法解决。

@howieyi
Copy link
Author

howieyi commented Jul 7, 2020

我还发现一个问题,就是异步获取数据渲染的时候,你们头部是优先渲染的,body异步之后渲染的,第一次渲染会错乱的宽度会比较夸张,不是这种1像素的差别,这就导致我还非得在数据获取完成后才能渲染table了
第一次
image
第二次
image

@zombieJ
Copy link
Member

zombieJ commented Jul 7, 2020

window 是根据当前分辨率来推荐缩放比,不是所有都是 125%。
另外这个是 windows 和 Chrome 的兼容问题,上面提过,我在代码端获取到非整数值后设置回去后 Fixed Header 还是对不齐这个就没办法了。

@afc163
Copy link
Member

afc163 commented Jul 29, 2020

关闭了,因为我们没好办法修复,有什么好的解决方案欢迎继续回复或给我们 PR。

@77soul
Copy link

77soul commented Jun 13, 2023

https://juejin.cn/post/7243796937199616037 好好学 好好看

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

4 participants