fix: calculate width and height with decimal #22778
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
carousel组件在计算宽高度的时候使用的是offsetWidth和offsetHeight,计算出来的只会是整数,但在有些情况下实际的宽度和高度会存在小数,例如在使用rem等为单位的情况下,误差零点几px的情况在chrome浏览器下(其他浏览器未进行测试)会导致当前页面展示了部分下一个非激活carousel-item的部分内容,比如carousel-item内元素的的最左侧存在border,会在当前active的carosuel-item的最右侧出现下一个非激活carousel-item的border,情况出现在使用offsetWidth计算出的宽度小于实际宽度的时候,也就是说比如当实际宽度是800.44而offsetWidth得到的值是800的时候会出现问题,而实际宽度是800.97offsetWidth得到的值是801的时候不会出现上述问题