Skip to content

Commit 276399e

Browse files
committed
Fix merge conflict.
2 parents 9f42dbf + b8c0cb3 commit 276399e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Source/JTSImageViewController.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ - (void)startImageDragging:(CGPoint)panGestureLocationInView translationOffset:(
15121512
self.attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.imageView offsetFromCenter:offset attachedToAnchor:anchor];
15131513
[self.animator addBehavior:self.attachmentBehavior];
15141514
UIDynamicItemBehavior *modifier = [[UIDynamicItemBehavior alloc] initWithItems:@[self.imageView]];
1515-
[modifier setAngularResistance:15];
1515+
[modifier setAngularResistance:[self appropriateAngularResistanceForView:self.imageView]];
15161516
[modifier setDensity:[self appropriateDensityForView:self.imageView]];
15171517
[self.animator addBehavior:modifier];
15181518
}
@@ -1562,6 +1562,19 @@ - (void)dismissImageWithFlick:(CGPoint)velocity {
15621562
[self.animator addBehavior:push];
15631563
}
15641564

1565+
- (CGFloat)appropriateAngularResistanceForView:(UIView *)view {
1566+
CGFloat height = view.bounds.size.height;
1567+
CGFloat width = view.bounds.size.width;
1568+
CGFloat actualArea = height * width;
1569+
CGFloat referenceArea = self.view.bounds.size.width * self.view.bounds.size.height;
1570+
CGFloat factor = referenceArea / actualArea;
1571+
CGFloat defaultResistance = 4.0f; // Feels good with a 1x1 on 3.5 inch displays. We'll adjust this to match the current display.
1572+
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
1573+
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
1574+
CGFloat resistance = defaultResistance * ((320.0 * 480.0) / (screenWidth * screenHeight));
1575+
return resistance * factor;
1576+
}
1577+
15651578
- (CGFloat)appropriateDensityForView:(UIView *)view {
15661579
CGFloat height = view.bounds.size.height;
15671580
CGFloat width = view.bounds.size.width;

0 commit comments

Comments
 (0)