Skip to content

Commit 7ea4315

Browse files
author
Joey Lorich
committed
Limit dragging when starting point is on the social toolbar or the social toolbar is visible
1 parent 94ed168 commit 7ea4315

27 files changed

Lines changed: 12283 additions & 12261 deletions

EasyReader/Application/Controllers/EZRHomeScrollViewDelegate.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ @implementation EZRHomeScrollViewDelegate
1313
{
1414
EZRHomeViewController *controller;
1515
NSString *currentURL;
16+
BOOL dragging;
17+
CGPoint dragStart;
1618
}
1719

1820
- (instancetype)initWithController:(EZRHomeViewController *)homeController
@@ -21,18 +23,41 @@ - (instancetype)initWithController:(EZRHomeViewController *)homeController
2123

2224
if (self) {
2325
controller = homeController;
26+
dragging = NO;
2427
}
2528

2629
return self;
2730
}
2831

2932
//
3033
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
34+
// Make scrolling back up to the top feel more natural
3135
if (scrollView.contentOffset.y == scrollView.frame.size.height) {
3236
if (controller.webView_feedItem.scrollView.contentOffset.y == 0) {
3337
controller.webView_feedItem.scrollView.contentOffset = CGPointMake(0, 1);
3438
}
3539
}
40+
41+
// Prevent collectionview scrolling when shar bar is showing
42+
if (scrollView.contentOffset.y < 0) {
43+
controller.collectionView_feedItems.userInteractionEnabled = NO;
44+
} else {
45+
controller.collectionView_feedItems.userInteractionEnabled = YES;
46+
}
47+
48+
// Don't allow drags from the share view to go past the base view without a stop
49+
if (dragging && dragStart.y < 0 && scrollView.contentOffset.y >= 0) {
50+
scrollView.contentOffset = CGPointMake(0,0);
51+
}
52+
}
53+
54+
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
55+
dragging = YES;
56+
dragStart = scrollView.contentOffset;
57+
}
58+
59+
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
60+
dragging = NO;
3661
}
3762

3863
/**

EasyReader/Application/Controllers/Home/EZRHomeViewController.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
/// Displays website that hosts article
4343
@property (nonatomic, strong) EZRNestableWebView *webView_feedItem;
4444

45-
@property (nonatomic, strong) UIToolbar *toolbar_webView;
46-
47-
@property (nonatomic, strong) UIImageView *upIndicatorView;
48-
49-
5045

5146
# pragma mark - Properties
5247

EasyReader/Application/Controllers/Home/EZRHomeViewController.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ @interface EZRHomeViewController()
4747
@property User *currentUser;
4848

4949

50-
///
50+
/// The current feeds provider object
5151
@property (nonatomic, strong) EZRCurrentFeedsProvider *currentFeedsProvider;
5252

53-
54-
53+
/// The social sharing toolbar
5554
@property (nonatomic, weak) IBOutlet CLDSocialShareToolbar *socialShareToolbar;
5655

56+
/// The up indicator displayed over the web view to assist in navigating to the top of the page
57+
@property (nonatomic, strong) UIImageView *upIndicatorView;
58+
5759
@end
5860

5961

0 commit comments

Comments
 (0)