diff options
author | Ilya Grechuhin <i.grechuhin@mapswithme.com> | 2015-06-22 16:36:08 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:52:47 +0300 |
commit | 4bd9e204c971becb23798b39f28b32c6e41e31f8 (patch) | |
tree | 009a81e924692840bd85b6925e50809d00d4eaa5 /iphone/Maps/Classes/MWMSpringAnimation.mm | |
parent | 83ebe0e2de836e0a9a1256c522c394aa39cd874a (diff) |
[ios] Fixed iPhone portrait PP scroll.
Diffstat (limited to 'iphone/Maps/Classes/MWMSpringAnimation.mm')
-rw-r--r-- | iphone/Maps/Classes/MWMSpringAnimation.mm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/iphone/Maps/Classes/MWMSpringAnimation.mm b/iphone/Maps/Classes/MWMSpringAnimation.mm index 47211011ef..6959784a8a 100644 --- a/iphone/Maps/Classes/MWMSpringAnimation.mm +++ b/iphone/Maps/Classes/MWMSpringAnimation.mm @@ -14,17 +14,18 @@ @property (nonatomic) CGPoint velocity; @property (nonatomic) CGPoint targetPoint; @property (nonatomic) UIView * view; +@property (copy, nonatomic) MWMSpringAnimationCompletionBlock completion; @end @implementation MWMSpringAnimation -+ (instancetype)animationWithView:(UIView *)view target:(CGPoint)target velocity:(CGPoint)velocity ++ (instancetype)animationWithView:(UIView *)view target:(CGPoint)target velocity:(CGPoint)velocity completion:(MWMSpringAnimationCompletionBlock)completion { - return [[self alloc] initWithView:view target:target velocity:velocity]; + return [[self alloc] initWithView:view target:target velocity:velocity completion:completion]; } -- (instancetype)initWithView:(UIView *)view target:(CGPoint)target velocity:(CGPoint)velocity +- (instancetype)initWithView:(UIView *)view target:(CGPoint)target velocity:(CGPoint)velocity completion:(MWMSpringAnimationCompletionBlock)completion { self = [super init]; if (self) @@ -32,6 +33,7 @@ self.view = view; self.targetPoint = target; self.velocity = velocity; + self.completion = completion; } return self; } @@ -58,7 +60,15 @@ { self.view.center = self.targetPoint; *finished = YES; + if (self.completion) + self.completion(); } } ++ (CGFloat)approxTargetFor:(CGFloat)startValue velocity:(CGFloat)velocity +{ + CGFloat const decelaration = (velocity > 0 ? -1.0 : 1.0) * 300.0; + return startValue - (velocity * velocity) / (2.0 * decelaration); +} + @end |