timecut
timecut copied to clipboard
Overriding native setTimeout is causing the application page to behave incorrectly
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?
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.
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
forDate
(as a class and forDate.now
) -
timeweb.realtime.setTimeout
forsetTimeout
-
timeweb.realtime.requestAnimationFrame
forrequestAnimationFrame
-
timeweb.realtime.setInterval
forsetInterval
-
timeweb.realtime.cancelAnimationFrame
forcancelAnimationFrame
-
timeweb.realtime.clearTimeout
forclearTimeout
-
timeweb.realtime.clearInterval
forclearInterval
-
timeweb.realtime.performance.now
forperformance.now
-
timeweb.realtime.createElement
fordocument.createElement
-
timeweb.realtime.createElementNS
fordocument.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
forDate
(as a class and forDate.now
) -
window._timeweb_oldSetTimeout
forsetTimeout
-
window._timeweb_oldRequestAnimationFrame
forrequestAnimationFrame
-
window._timeweb_oldSetInterval
forsetInterval
-
window._timeweb_oldCancelAnimationFrame
forcancelAnimationFrame
-
window._timeweb_oldClearTimeout
forclearTimeout
-
window._timeweb_oldClearInterval
forclearInterval
-
window._timeweb_oldPerformanceNow
forperformance.now
-
document._timeweb_oldCreateElement
fordocument.createElement
-
document._timeweb_oldCreateElementNS
fordocument.createElementNS