diff options
Diffstat (limited to 'platform/ios/vendor/SMCalloutView/SMCalloutView.m')
-rwxr-xr-x | platform/ios/vendor/SMCalloutView/SMCalloutView.m | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/platform/ios/vendor/SMCalloutView/SMCalloutView.m b/platform/ios/vendor/SMCalloutView/SMCalloutView.m index 0520ba08a5..06626f9497 100755 --- a/platform/ios/vendor/SMCalloutView/SMCalloutView.m +++ b/platform/ios/vendor/SMCalloutView/SMCalloutView.m @@ -520,52 +520,58 @@ NSTimeInterval const kMGLSMCalloutViewRepositionDelayForUIScrollView = 1.0/3.0; - (CAAnimation *)animationWithType:(MGLSMCalloutAnimation)type presenting:(BOOL)presenting { CAAnimation *animation = nil; - if (type == MGLSMCalloutAnimationBounce) { - - CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"]; - fade.duration = 0.23; - fade.fromValue = presenting ? @0.0 : @1.0; - fade.toValue = presenting ? @1.0 : @0.0; - fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - - CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; - bounce.duration = 0.23; - bounce.fromValue = presenting ? @0.7 : @1.0; - bounce.toValue = presenting ? @1.0 : @0.7; - bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814]; - - CAAnimationGroup *group = [CAAnimationGroup animation]; - group.animations = @[fade, bounce]; - group.duration = 0.23; - - animation = group; - } - else if (type == MGLSMCalloutAnimationFade) { - CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"]; - fade.duration = 1.0/3.0; - fade.fromValue = presenting ? @0.0 : @1.0; - fade.toValue = presenting ? @1.0 : @0.0; - animation = fade; - } - else if (type == MGLSMCalloutAnimationStretch) { - CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; - stretch.duration = 0.1; - stretch.fromValue = presenting ? @0.0 : @1.0; - stretch.toValue = presenting ? @1.0 : @0.0; - animation = stretch; + switch (type) + { + case MGLSMCalloutAnimationBounce: + { + CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"]; + fade.duration = 0.23; + fade.fromValue = presenting ? @0.0 : @1.0; + fade.toValue = presenting ? @1.0 : @0.0; + fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + + CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; + bounce.duration = 0.23; + bounce.fromValue = presenting ? @0.7 : @1.0; + bounce.toValue = presenting ? @1.0 : @0.7; + bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814]; + + CAAnimationGroup *group = [CAAnimationGroup animation]; + group.animations = @[fade, bounce]; + group.duration = 0.23; + + animation = group; + break; + } + + case MGLSMCalloutAnimationFade: + { + CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"]; + fade.duration = 1.0/3.0; + fade.fromValue = presenting ? @0.0 : @1.0; + fade.toValue = presenting ? @1.0 : @0.0; + animation = fade; + break; + } + + case MGLSMCalloutAnimationStretch: + { + CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; + stretch.duration = 0.1; + stretch.fromValue = presenting ? @0.0 : @1.0; + stretch.toValue = presenting ? @1.0 : @0.0; + animation = stretch; + break; + } } - - NSAssert(animation, @"There should be an animation"); - + // CAAnimation is KVC compliant, so we can store whether we're presenting for lookup in our delegate methods [animation setValue:@(presenting) forKey:@"presenting"]; animation.fillMode = kCAFillModeForwards; animation.removedOnCompletion = NO; - // Cast as non-null to mute static analysis warning as documented at - // https://clang-analyzer.llvm.org/faq.html#decide_nullability - return (CAAnimation * _Nonnull)animation; + return animation; } - (void)layoutSubviews { |