hooks icon indicating copy to clipboard operation
hooks copied to clipboard

useSize 返回结果为整数,但实际元素尺寸可能为小数

Open CJY0208 opened this issue 2 years ago • 0 comments

目前使用 clientWidth、clientHeight 取值,结果为整数,但实际元素尺寸可能为小数,可能会导致高精度需求场景下的数值误差

https://github.com/alibaba/hooks/blob/2d82a3fbde5cc08963e988a78bdbe8395e831382/packages/hooks/src/useSize/index.ts#L20-L28

是否可以考虑调整为 getBoundingClientRect().height 获取高精度数值?或者增加参数开启高精度模式,不影响此前行为

image

参考:HTMLElement.offsetHeight

CJY0208 avatar Nov 16 '21 10:11 CJY0208