mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Native Animated - Support decay on iOS
Summary: This is one of the last feature that is missing from native animated, it was already supported on Android and this implementation is based on it. **Test plan** Test that the existing decay animation example now works on iOS Run unit tests Closes https://github.com/facebook/react-native/pull/13368 Differential Revision: D4938061 Pulled By: javache fbshipit-source-id: 36b57b1029a542e9daf21e048a06d3b3347e9659
This commit is contained in:
committed by
Facebook Github Bot
parent
f1d5fdd468
commit
6c434f9404
@@ -17,8 +17,6 @@
|
||||
#import "RCTAnimationUtils.h"
|
||||
#import "RCTValueAnimatedNode.h"
|
||||
|
||||
const double SINGLE_FRAME_INTERVAL = 1.0 / 60.0;
|
||||
|
||||
@interface RCTFrameAnimation ()
|
||||
|
||||
@property (nonatomic, strong) NSNumber *animationId;
|
||||
@@ -91,7 +89,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
// Determine how many frames have passed since last update.
|
||||
// Get index of frames that surround the current interval
|
||||
NSUInteger startIndex = floor(currentDuration / SINGLE_FRAME_INTERVAL);
|
||||
NSUInteger startIndex = floor(currentDuration / RCTSingleFrameInterval);
|
||||
NSUInteger nextIndex = startIndex + 1;
|
||||
|
||||
if (nextIndex >= _frames.count) {
|
||||
@@ -106,8 +104,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
// Do a linear remap of the two frames to safegaurd against variable framerates
|
||||
NSNumber *fromFrameValue = _frames[startIndex];
|
||||
NSNumber *toFrameValue = _frames[nextIndex];
|
||||
NSTimeInterval fromInterval = startIndex * SINGLE_FRAME_INTERVAL;
|
||||
NSTimeInterval toInterval = nextIndex * SINGLE_FRAME_INTERVAL;
|
||||
NSTimeInterval fromInterval = startIndex * RCTSingleFrameInterval;
|
||||
NSTimeInterval toInterval = nextIndex * RCTSingleFrameInterval;
|
||||
|
||||
// Interpolate between the individual frames to ensure the animations are
|
||||
//smooth and of the proper duration regardless of the framerate.
|
||||
|
||||
Reference in New Issue
Block a user