react-native-navigation的迁移库

ElementAnimator.m 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import "ElementAnimator.h"
  2. #import "ElementAlphaTransition.h"
  3. #import "ElementVerticalTransition.h"
  4. #import "ElementHorizontalTransition.h"
  5. #import "HorizontalTranslationTransition.h"
  6. #import "VerticalTranslationTransition.h"
  7. #import "Transition.h"
  8. #import "RNNElementFinder.h"
  9. #import "VerticalRotationTransition.h"
  10. @implementation ElementAnimator {
  11. UIViewController* _toVC;
  12. UIViewController* _fromVC;
  13. UIView* _containerView;
  14. }
  15. - (instancetype)initWithTransitionOptions:(ElementTransitionOptions *)transitionOptions view:(UIView *)view fromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC containerView:(UIView *)containerView {
  16. self = [super init];
  17. _fromVC = fromVC;
  18. _toVC = toVC;
  19. _containerView = containerView;
  20. self.view = view;
  21. self.animations = [self createAnimations:transitionOptions];
  22. return self;
  23. }
  24. - (NSMutableArray<id<DisplayLinkAnimation>> *)createAnimations:(ElementTransitionOptions *)transitionOptions {
  25. NSMutableArray* animations = [NSMutableArray new];
  26. if (transitionOptions.alpha.hasAnimation) {
  27. [animations addObject:[[ElementAlphaTransition alloc] initWithView:self.view transitionDetails:transitionOptions.alpha]];
  28. }
  29. if (transitionOptions.x.hasAnimation) {
  30. [animations addObject:[[ElementHorizontalTransition alloc] initWithView:self.view transitionDetails:transitionOptions.x]];
  31. }
  32. if (transitionOptions.y.hasAnimation) {
  33. [animations addObject:[[ElementVerticalTransition alloc] initWithView:self.view transitionDetails:transitionOptions.y]];
  34. }
  35. if (transitionOptions.translationX.hasAnimation) {
  36. [animations addObject:[[HorizontalTranslationTransition alloc] initWithView:self.view transitionDetails:transitionOptions.translationX]];
  37. }
  38. if (transitionOptions.translationY.hasAnimation) {
  39. [animations addObject:[[VerticalTranslationTransition alloc] initWithView:self.view transitionDetails:transitionOptions.translationY]];
  40. }
  41. if (transitionOptions.rotationY.hasAnimation) {
  42. [animations addObject:[[VerticalRotationTransition alloc] initWithView:self.view transitionDetails:transitionOptions.rotationY]];
  43. }
  44. return animations;
  45. }
  46. @end