From 150e657f5cfa0488b260b615d237ee3d7e191534 Mon Sep 17 00:00:00 2001 From: janlionly Date: Thu, 27 May 2021 18:12:19 +0800 Subject: [PATCH 1/2] fix: Avoid dragging downwards or upwards to close the image(especially for the portrait image) when enlarge it to preview. --- BFRImageViewController/BFRImageContainerViewController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BFRImageViewController/BFRImageContainerViewController.m b/BFRImageViewController/BFRImageContainerViewController.m index dd50b9c..404237b 100644 --- a/BFRImageViewController/BFRImageContainerViewController.m +++ b/BFRImageViewController/BFRImageContainerViewController.m @@ -266,6 +266,9 @@ - (void)handleHiResImageDownloaded:(NSNotification *)note { // If we have more than one image, this will cancel out dragging horizontally to make it easy to navigate between images - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self.scrollView]; + if (self.scrollView.zoomScale > 1) { + return NO; + } return fabs(velocity.y) > fabs(velocity.x); } @@ -370,7 +373,6 @@ - (void)handleDrag:(UIPanGestureRecognizer *)recognizer { [self.animator removeAllBehaviors]; self.activeAssetView.userInteractionEnabled = NO; self.scrollView.userInteractionEnabled = NO; - UIGravityBehavior *exitGravity = [[UIGravityBehavior alloc] initWithItems:@[self.activeAssetView]]; if (CGRectContainsPoint(closeTopThreshhold, location)) { exitGravity.gravityDirection = CGVectorMake(0.0, -1.0); From 56ebb45461e8bd177151a988bb7403255f215af4 Mon Sep 17 00:00:00 2001 From: janlionly Date: Thu, 27 May 2021 19:03:27 +0800 Subject: [PATCH 2/2] fix: If there's only one image, avoid dragging the image to get back to 1X when enlarge it to preview on iOS devices --- BFRImageViewController/BFRImageContainerViewController.h | 3 --- BFRImageViewController/BFRImageContainerViewController.m | 5 ++--- BFRImageViewController/BFRImageViewController.m | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/BFRImageViewController/BFRImageContainerViewController.h b/BFRImageViewController/BFRImageContainerViewController.h index 9056925..4763d0c 100644 --- a/BFRImageViewController/BFRImageContainerViewController.h +++ b/BFRImageViewController/BFRImageContainerViewController.h @@ -37,9 +37,6 @@ typedef NS_ENUM(NSUInteger, BFRImageAssetType) { /*! Assigning YES to this property will disable long pressing media to present the activity view controller. You typically don't set this property yourself, instead, the value is derived from the containing @c BFRImageViewController instance. */ @property (nonatomic, getter=shouldDisableSharingLongPress) BOOL disableSharingLongPress; -/*! If there is more than one image in the containing @c BFRImageViewController - this property is set to YES to make swiping from image to image easier. */ -@property (nonatomic, getter=shouldDisableHorizontalDrag) BOOL disableHorizontalDrag; - /*! Assigning YES to this property will disable autoplay for live photos when it used with 3DTouch peek feature */ @property (nonatomic, getter=shouldDisableAutoplayForLivePhoto) BOOL disableAutoplayForLivePhoto; @property (nonatomic, assign) CGFloat imageMaxScale; diff --git a/BFRImageViewController/BFRImageContainerViewController.m b/BFRImageViewController/BFRImageContainerViewController.m index 404237b..4ff550d 100644 --- a/BFRImageViewController/BFRImageContainerViewController.m +++ b/BFRImageViewController/BFRImageContainerViewController.m @@ -224,9 +224,8 @@ - (void)createActiveAssetView { // Dragging to dismiss UIPanGestureRecognizer *panImg = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleDrag:)]; - if (self.shouldDisableHorizontalDrag) { - panImg.delegate = self; - } + panImg.delegate = self; + [resizableImageView addGestureRecognizer:panImg]; if (self.assetType == BFRImageAssetTypeLivePhoto) { diff --git a/BFRImageViewController/BFRImageViewController.m b/BFRImageViewController/BFRImageViewController.m index 708a5c1..1900dfd 100644 --- a/BFRImageViewController/BFRImageViewController.m +++ b/BFRImageViewController/BFRImageViewController.m @@ -184,7 +184,6 @@ - (void)reinitializeUI { imgVC.usedFor3DTouch = self.isBeingUsedFor3DTouch; imgVC.useTransparentBackground = self.isUsingTransparentBackground; imgVC.disableSharingLongPress = self.shouldDisableSharingLongPress; - imgVC.disableHorizontalDrag = (self.images.count > 1); imgVC.disableAutoplayForLivePhoto = self.shouldDisableAutoplayForLivePhoto; imgVC.imageMaxScale = self.maxScale; [self.imageViewControllers addObject:imgVC];