Skip to content

Commit

Permalink
Fix merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsinclair committed May 26, 2014
2 parents 9f42dbf + b8c0cb3 commit 276399e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/JTSImageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ - (void)startImageDragging:(CGPoint)panGestureLocationInView translationOffset:(
self.attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.imageView offsetFromCenter:offset attachedToAnchor:anchor];
[self.animator addBehavior:self.attachmentBehavior];
UIDynamicItemBehavior *modifier = [[UIDynamicItemBehavior alloc] initWithItems:@[self.imageView]];
[modifier setAngularResistance:15];
[modifier setAngularResistance:[self appropriateAngularResistanceForView:self.imageView]];
[modifier setDensity:[self appropriateDensityForView:self.imageView]];
[self.animator addBehavior:modifier];
}
Expand Down Expand Up @@ -1562,6 +1562,19 @@ - (void)dismissImageWithFlick:(CGPoint)velocity {
[self.animator addBehavior:push];
}

- (CGFloat)appropriateAngularResistanceForView:(UIView *)view {
CGFloat height = view.bounds.size.height;
CGFloat width = view.bounds.size.width;
CGFloat actualArea = height * width;
CGFloat referenceArea = self.view.bounds.size.width * self.view.bounds.size.height;
CGFloat factor = referenceArea / actualArea;
CGFloat defaultResistance = 4.0f; // Feels good with a 1x1 on 3.5 inch displays. We'll adjust this to match the current display.
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
CGFloat resistance = defaultResistance * ((320.0 * 480.0) / (screenWidth * screenHeight));
return resistance * factor;
}

- (CGFloat)appropriateDensityForView:(UIView *)view {
CGFloat height = view.bounds.size.height;
CGFloat width = view.bounds.size.width;
Expand Down

0 comments on commit 276399e

Please sign in to comment.