Skip to content

Commit

Permalink
Fixes transitioning API delay when delayMs is not set (#335)
Browse files Browse the repository at this point in the history
After implamenting "Slow Transitions" feature an issue was introduced with Transitioning API as you can see here tomasgcs/react-native-reanimated@4ef8b81#diff-a7ea5763fc80cde0b741dca6a5095a18R46

Previously beginTime variable was not set at all which was equal to 0, but after this specific line was added the value is different, and it causes animations to delay even if delayMs value is not set, this happens only when animation is is being executed multiple times.

Not sure why this is happening but most likely that CACurrentMediaTime() introduces delay even if it takes current time. In my case it is very important to run animations as fast as possible so I've sumbitted a fix here.
  • Loading branch information
tomasgcs authored and osdnk committed Nov 12, 2019
1 parent 4b24792 commit d0f39f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion ios/Transitioning/REATransitionAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ + (REATransitionAnimation *)transitionWithAnimation:(CAAnimation *)animation

- (void)play
{
/*
CACurrentMediaTime introduces some kind of delay even if _delay is set to 0
it calls mach_absolute_time() which is based on the last time the device booted
which might cause the delay
*/
if (_delay > 0){
_animation.beginTime = CACurrentMediaTime() + _delay * SimAnimationDragCoefficient();
}
_animation.duration = self.duration * SimAnimationDragCoefficient();
_animation.beginTime = CACurrentMediaTime() + _delay * SimAnimationDragCoefficient();
[_layer addAnimation:_animation forKey:_keyPath];
}

Expand Down
2 changes: 1 addition & 1 deletion src/animations/backwardCompatibleAnimWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
startClock,
stopClock,
} from '../base';
import { clock as Clock } from '../core/AnimatedClock';
import { default as Clock } from '../core/AnimatedClock';
import { evaluateOnce } from '../derived/evaluateOnce';

function createOldAnimationObject(node, AnimationClass, value, config) {
Expand Down

0 comments on commit d0f39f2

Please sign in to comment.