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

Countdown 组件计时精度错误,倒计时结束事件实际在 -1 秒时触发。 #2910

Closed
hmingv opened this issue May 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@hmingv
Copy link

hmingv commented May 10, 2022

TuSimple/naive-ui version (版本)

2.28.2

Vue version (Vue 版本)

3.2.33

Browser and its version (浏览器及其版本)

所有主流浏览器

System and its version (系统及其版本)

Windows

Node version (Node 版本)

Reappearance link (重现链接)

https://github.com/TuSimple/naive-ui/blob/main/src/countdown/src/Countdown.tsx#L58

Reappearance steps (重现步骤)

使用 Downcount 组件,设置倒计时 五秒钟,precision 设为默认值(0)。

在源码 frame 方法中打印 const distance = getDistance(performance.now()) 代码声明的 distance 变量,会发现精度错误。

并监听 finish 事件,在 0 秒时此事件不会触发,再过一秒后触发。

Expected results (期望的结果)

在 0 秒时触发 finish 事件。

Actual results (实际的结果)

实际在 0 秒后再过一秒才会触发时间

Remarks (补充说明)

解决精度问题

@github-actions github-actions bot added the untriaged need to sort label May 10, 2022
@07akioni 07akioni added the bug Something isn't working label May 10, 2022
@07akioni 07akioni removed the untriaged need to sort label May 10, 2022
@07akioni
Copy link
Collaborator

这个主要原因是 4.0 ~ 4.9 秒现实中应该被显示为 5 秒,但是之前实现成了 4 秒

@07akioni
Copy link
Collaborator

所以 duration 实际是没问题的,问题是出在了显示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants