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

Overriding native setTimeout is causing the application page to behave incorrectly #26

Open
subhadeepguin opened this issue Dec 9, 2019 · 2 comments

Comments

@subhadeepguin
Copy link

Hi,
We are trying to use timecut to animate one of the application page which uses native setTimeout functions to show a few elements on page. While using this application page with timecut, we noticed that the features (using setTimeout) are behaving incorrectly. after digging down a bit, we noticed that timecut overrides the native function which is causing this issue. Any suggestions on how to use timecut for this kind of application?

@frizurd
Copy link

frizurd commented Sep 4, 2020

Did you find a solution?

Having the same issue, I use setInterval to check if external fonts have finished loading but the setInterval functionality never fires when Timecut is doing its job.

I'm using webfontloader to load the fonts, which has an onLoaded event callback but this also doesn't fire with Timecut.

Trying to hack my way into a solution, will keep you updated if I find one.

@tungs
Copy link
Owner

tungs commented Jan 26, 2021

timecut works by overwriting time handling functions, including setTimeout, to virtual ones. Currently it doesn't allow users to not overwrite these functions, but it provides access to the old, realtime functions, via the timeweb.realtime property.

v0.3.1+ of timecut (The Current Way, though undocumented)

  • timeweb.realtime.Date for Date (as a class and for Date.now)
  • timeweb.realtime.setTimeout for setTimeout
  • timeweb.realtime.requestAnimationFrame for requestAnimationFrame
  • timeweb.realtime.setInterval for setInterval
  • timeweb.realtime.cancelAnimationFrame for cancelAnimationFrame
  • timeweb.realtime.clearTimeout for clearTimeout
  • timeweb.realtime.clearInterval for clearInterval
  • timeweb.realtime.performance.now for performance.now
  • timeweb.realtime.createElement for document.createElement
  • timeweb.realtime.createElementNS for document.createElementNS

v0.2.0-v0.3.0 of timecut (Undocumented)

For versions of v0.2.0-v0.3.0 of timecut, the overwritten time handling functions were available via the _timeweb_old prefix. They were removed in v0.3.1 of timecut (which was a result of the move to timeweb v0.2.0), in favor of the above method:

  • window._timeweb_oldDate for Date (as a class and for Date.now)
  • window._timeweb_oldSetTimeout for setTimeout
  • window._timeweb_oldRequestAnimationFrame for requestAnimationFrame
  • window._timeweb_oldSetInterval for setInterval
  • window._timeweb_oldCancelAnimationFrame for cancelAnimationFrame
  • window._timeweb_oldClearTimeout for clearTimeout
  • window._timeweb_oldClearInterval for clearInterval
  • window._timeweb_oldPerformanceNow for performance.now
  • document._timeweb_oldCreateElement for document.createElement
  • document._timeweb_oldCreateElementNS for document.createElementNS

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

No branches or pull requests

3 participants