Skip to content

Commit afeb037

Browse files
committed
fix(Timing): Fix behavior for requestAnimationFrame.
Previously, the requestAnimationFrame callbacks occured on a tight loop. Ensuring that only immediate timers callback instantly. Fixes microsoft#394
1 parent dfc4d35 commit afeb037

File tree

1 file changed

+5
-5
lines changed
  • ReactWindows/ReactNative/Modules/Core

1 file changed

+5
-5
lines changed

ReactWindows/ReactNative/Modules/Core/Timing.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ public void createTimer(
106106
double jsSchedulingTime,
107107
bool repeat)
108108
{
109-
var period = TimeSpan.FromMilliseconds(duration);
110-
var scheduledTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsSchedulingTime);
111-
var initialTargetTime = (scheduledTime + period);
112-
113-
if (DateTimeOffset.Now > initialTargetTime && !repeat)
109+
if (duration == 0 && !repeat)
114110
{
115111
_jsTimersModule.callTimers(new[] { callbackId });
116112
return;
117113
}
118114

115+
var period = TimeSpan.FromMilliseconds(duration);
116+
var scheduledTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsSchedulingTime);
117+
var initialTargetTime = (scheduledTime + period);
118+
119119
var timer = new TimerData(callbackId, initialTargetTime, period, repeat);
120120
lock (_gate)
121121
{

0 commit comments

Comments
 (0)