Coder Social home page Coder Social logo

Comments (6)

fengyuanchen avatar fengyuanchen commented on July 20, 2024

Good discovery. I will improve this soon.

from vue-countdown.

u01jmg3 avatar u01jmg3 commented on July 20, 2024

Thanks for making this change so quickly.

However, when comparing to various physical stopwatches over 7 minutes I am finding that the countdown *still* lags behind real time.

Have you tried this type of testing?

from vue-countdown.

fengyuanchen avatar fengyuanchen commented on July 20, 2024

As a browser-side count down component, I think it is hard to be accurate as a physical stopwatch. I guess it may have a deviation of ±0.5s per minute (±8ms per step) when using the window.requestAnimationFrame function.

from vue-countdown.

u01jmg3 avatar u01jmg3 commented on July 20, 2024

Do you think it would be a good idea to have a way of not using window.requestAnimationFrame (and instead defaulting to setTimeout())?

from vue-countdown.

fengyuanchen avatar fengyuanchen commented on July 20, 2024

@u01jmg3 See #33.

from vue-countdown.

klesun avatar klesun commented on July 20, 2024

Hi. We observe that the library still produces a time error that becomes clearly noticeable after an hour of work, the error seems to depend on tab activity.

In my humble opinion the core of the timing issue is actually here:

progress() {
  this.totalMilliseconds -= this.interval;

The library decrements the totalMilliseconds by a fixed interval value not accounting for the real time that tick took which can be off from the requested time by few milliseconds depending on stuff like CPU load - those milliseconds slowly accumulate over time.

I think what would be conceptually correct here is:

progress() {
    this.totalMilliseconds = this.endTime - Date.now();

That way we would eliminate the time error by making totalMilliseconds to get decremented by the effective time that tick took rather than the time that we requested from the unreliable OS.

from vue-countdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.