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

elevator组件elevator__item__${i}渲染出现小数 #1844

Closed
yuanxin42 opened this issue Nov 15, 2022 · 1 comment
Closed

elevator组件elevator__item__${i}渲染出现小数 #1844

yuanxin42 opened this issue Nov 15, 2022 · 1 comment
Assignees

Comments

@yuanxin42
Copy link

NutUI scenes(nutui 场景)

H5(@nutui/nutui)微信小程序

Reproduction link(重现链接)

nutui.jd.com

Steps to reproduce(重现步骤)

渲染数据,然后点击右侧的小标,会偶现定位不准确的情况

What is expected?(期望的结果是什么?)

点击哪个,定位到哪个

What is actually happening?(实际的结果是什么?)

定位不准确

问题会出现定位不准确的情况,复现视频如下

1668503057722186.mp4

原因:渲染的时候,偶尔会出现高度为小数的情况(打印的 state.listHeight)
image

Remarks(补充说明)

希望在初始化高度的时候,可以加上Math.floor,处理一下小数的情况
height += Math.floor(res[i][0].height);

对应函数如下:

const calculateHeight = () => {
state.listHeight = [];
let height = 0;
state.listHeight.push(height);
for (let i = 0; i < state.listGroup.length; i++) {
state.query.selectAll(.elevator__item__${i}).boundingClientRect();
state.query.exec((res) => {
height += Math.floor(res[i][0].height);
console.log(height, '看看初始化的时候每个高度是多少--');
state.listHeight.push(height);
});
}
};

@szg2008
Copy link
Contributor

szg2008 commented Dec 1, 2022

感谢反馈和更正,下个版本修复🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants