react-native-navigation的迁移库

AnchorTransition.m 875B

1234567891011121314151617181920212223
  1. #import "AnchorTransition.h"
  2. #import "RNNInterpolator.h"
  3. @implementation AnchorTransition {
  4. CGPoint _initialPoint;
  5. }
  6. - (instancetype)initWithView:(UIView *)view from:(CGPoint)from to:(CGPoint)to startDelay:(NSTimeInterval)startDelay duration:(NSTimeInterval)duration interpolation:(Text *)interpolation {
  7. self = [super initWithView:view startDelay:startDelay duration:duration interpolation:interpolation];
  8. _initialPoint = from;
  9. _from = from;
  10. _to = to;
  11. return self;
  12. }
  13. - (CATransform3D)animateWithProgress:(CGFloat)p {
  14. CGFloat x = [RNNInterpolator fromFloat:self.from.x toFloat:self.to.x precent:p interpolation:self.interpolation];
  15. CGFloat y = [RNNInterpolator fromFloat:self.from.y toFloat:self.to.y precent:p interpolation:self.interpolation];
  16. return CATransform3DMakeTranslation(x - _initialPoint.x, y - _initialPoint.y, 0);
  17. }
  18. @end