Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid dragging downwards or upwards to close the image(especially for the portrait image) when enlarge it to preview on iOS devices. #100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions BFRImageViewController/BFRImageContainerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions BFRImageViewController/BFRImageContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -266,6 +265,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);
}

Expand Down Expand Up @@ -370,7 +372,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);
Expand Down
1 change: 0 additions & 1 deletion BFRImageViewController/BFRImageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down