From 5b91a25ad08e5f3a52beea93b6447f3e96af17ba Mon Sep 17 00:00:00 2001 From: Pin Shih Wang Date: Thu, 3 Jul 2014 00:10:43 +0800 Subject: [PATCH 1/4] adding parallaxScrollView:didEndScrollingAnimation: delegate method. adding enabling feature. --- PWParallaxScrollView.podspec | 4 ++-- PWParallaxScrollView/PWParallaxScrollView.h | 2 ++ PWParallaxScrollView/PWParallaxScrollView.m | 26 ++++++++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/PWParallaxScrollView.podspec b/PWParallaxScrollView.podspec index 3538c19..51dbceb 100755 --- a/PWParallaxScrollView.podspec +++ b/PWParallaxScrollView.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "PWParallaxScrollView" - s.version = "1.1.0" + s.version = "1.1.5" s.summary = "PWParallaxScrollView is a library for creating sliding menus with parallax effect inspired by the WWF app" s.homepage = "http://www.github.com/wpsteak/PWParallaxScrollView" s.screenshots = "https://raw.githubusercontent.com/wpsteak/PWParallaxScrollView/master/screenshot.png" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "wpsteak" => "wpsteak@gmail.com" } s.platform = :ios - s.source = { :git => "https://github.com/wpsteak/PWParallaxScrollView.git", :tag => "1.1.0" } + s.source = { :git => "https://github.com/wpsteak/PWParallaxScrollView.git", :tag => "1.1.5" } s.source_files = 'PWParallaxScrollView/*.{h,m}' s.requires_arc = true end diff --git a/PWParallaxScrollView/PWParallaxScrollView.h b/PWParallaxScrollView/PWParallaxScrollView.h index 1f54672..2cbd359 100755 --- a/PWParallaxScrollView/PWParallaxScrollView.h +++ b/PWParallaxScrollView/PWParallaxScrollView.h @@ -19,6 +19,7 @@ @property (nonatomic, assign) UIEdgeInsets foregroundScreenEdgeInsets; @property (nonatomic, assign) NSInteger maxAllowableItem; +@property (nonatomic, assign) BOOL enabled; - (void)prevItem; - (void)nextItem; @@ -43,6 +44,7 @@ - (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didChangeIndex:(NSInteger)index; - (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didEndDeceleratingAtIndex:(NSInteger)index; - (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didRecieveTapAtIndex:(NSInteger)index; +- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didEndScrollingAnimation:(NSInteger)index; @end diff --git a/PWParallaxScrollView/PWParallaxScrollView.m b/PWParallaxScrollView/PWParallaxScrollView.m index c7c1538..8ad97a7 100755 --- a/PWParallaxScrollView/PWParallaxScrollView.m +++ b/PWParallaxScrollView/PWParallaxScrollView.m @@ -92,14 +92,18 @@ - (void)initControl [self addSubview:_backgroundScrollView]; [self addSubview:_foregroundScrollView]; [self addSubview:_touchScrollView]; + + _enabled = YES; } #pragma mark - public method - (void)moveToIndex:(NSInteger)index { - CGFloat newOffsetX = index * CGRectGetWidth(_touchScrollView.frame); - [_touchScrollView scrollRectToVisible:CGRectMake(newOffsetX, 0, CGRectGetWidth(_touchScrollView.frame), CGRectGetHeight(_touchScrollView.frame)) animated:YES]; + if (_enabled) { + CGFloat newOffsetX = index * CGRectGetWidth(_touchScrollView.frame); + [_touchScrollView scrollRectToVisible:CGRectMake(newOffsetX, 0, CGRectGetWidth(_touchScrollView.frame), CGRectGetHeight(_touchScrollView.frame)) animated:YES]; + } } - (void)prevItem @@ -144,6 +148,15 @@ - (void)reloadData } } +- (void)setEnabled:(BOOL)enabled +{ + _enabled = enabled; + _touchScrollView.multipleTouchEnabled = enabled; + _touchScrollView.pagingEnabled = enabled; + _backgroundScrollView.pagingEnabled = enabled; + _touchScrollView.delegate = (enabled? self : nil); +} + #pragma mark - private method - (void)touchScrollViewTapped:(id)sender { @@ -304,6 +317,13 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView } } +- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + if([self.delegate respondsToSelector:@selector(parallaxScrollView:didEndScrollingAnimation:)]){ + [self.delegate parallaxScrollView:self didEndScrollingAnimation:self.currentIndex]; + } +} + #pragma mark hitTest - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { @@ -316,7 +336,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event } } - return [super hitTest:point withEvent:event]; + return (_enabled)? [super hitTest:point withEvent:event] : nil; } @end From 5a64fdbecd3d62cb613a139e9e7d68cf04a00891 Mon Sep 17 00:00:00 2001 From: Irad Ratmansky Date: Mon, 20 Oct 2014 15:55:28 +0300 Subject: [PATCH 2/4] adding lock\unlock button to the example. --- PWParallaxScrollViewExample/ViewController.m | 12 ++++++++ .../en.lproj/ViewController_iPad.xib | 27 +++++++++++++----- .../en.lproj/ViewController_iPhone.xib | 28 +++++++++++++------ 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/PWParallaxScrollViewExample/ViewController.m b/PWParallaxScrollViewExample/ViewController.m index 47ca527..ddc8e55 100755 --- a/PWParallaxScrollViewExample/ViewController.m +++ b/PWParallaxScrollViewExample/ViewController.m @@ -15,6 +15,8 @@ @interface ViewController () - + - - + + @@ -18,7 +18,6 @@ - + + + + + + diff --git a/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib b/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib index 4ae77f6..3915326 100755 --- a/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib +++ b/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib @@ -1,12 +1,13 @@ - + - + + @@ -18,7 +19,6 @@ - + - - + + + + + From b60daff37a1e5305e44c0eba4c1f94a097224619 Mon Sep 17 00:00:00 2001 From: Irad Ratmansky Date: Tue, 28 Oct 2014 13:28:12 +0200 Subject: [PATCH 3/4] adding an option to hide the scroller indication. --- .../xcshareddata/PWParallaxScrollView.xccheckout | 16 ++++++++-------- PWParallaxScrollView/PWParallaxScrollView.h | 1 + PWParallaxScrollView/PWParallaxScrollView.m | 6 ++++++ PWParallaxScrollViewExample/ViewController.m | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout b/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout index e7c1140..ed23ed2 100644 --- a/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout +++ b/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout @@ -10,29 +10,29 @@ PWParallaxScrollView IDESourceControlProjectOriginsDictionary - 0D02EFF2-E474-4994-9FFA-5E26408D6717 - https://github.com/wpsteak/PWParallaxScrollView.git + 3E183C459E55170D25FCA0466CE3115E287F8D92 + github.com:iradicator/PWParallaxScrollView.git IDESourceControlProjectPath - PWParallaxScrollView.xcodeproj/project.xcworkspace + PWParallaxScrollView.xcodeproj IDESourceControlProjectRelativeInstallPathDictionary - 0D02EFF2-E474-4994-9FFA-5E26408D6717 + 3E183C459E55170D25FCA0466CE3115E287F8D92 ../.. IDESourceControlProjectURL - https://github.com/wpsteak/PWParallaxScrollView.git + github.com:iradicator/PWParallaxScrollView.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - 0D02EFF2-E474-4994-9FFA-5E26408D6717 + 3E183C459E55170D25FCA0466CE3115E287F8D92 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - 0D02EFF2-E474-4994-9FFA-5E26408D6717 + 3E183C459E55170D25FCA0466CE3115E287F8D92 IDESourceControlWCCName PWParallaxScrollView diff --git a/PWParallaxScrollView/PWParallaxScrollView.h b/PWParallaxScrollView/PWParallaxScrollView.h index 2cbd359..74b9fca 100755 --- a/PWParallaxScrollView/PWParallaxScrollView.h +++ b/PWParallaxScrollView/PWParallaxScrollView.h @@ -20,6 +20,7 @@ @property (nonatomic, assign) NSInteger maxAllowableItem; @property (nonatomic, assign) BOOL enabled; +@property (nonatomic, assign) BOOL showsScrollIndicator; - (void)prevItem; - (void)nextItem; diff --git a/PWParallaxScrollView/PWParallaxScrollView.m b/PWParallaxScrollView/PWParallaxScrollView.m index 8ad97a7..0e915f7 100755 --- a/PWParallaxScrollView/PWParallaxScrollView.m +++ b/PWParallaxScrollView/PWParallaxScrollView.m @@ -157,6 +157,12 @@ - (void)setEnabled:(BOOL)enabled _touchScrollView.delegate = (enabled? self : nil); } +- (void)setShowsScrollIndicator:(BOOL)showsScrollIndicator { + _touchScrollView.showsHorizontalScrollIndicator = showsScrollIndicator; + _foregroundScrollView.showsHorizontalScrollIndicator = showsScrollIndicator; + _backgroundScrollView.showsHorizontalScrollIndicator = showsScrollIndicator; +} + #pragma mark - private method - (void)touchScrollViewTapped:(id)sender { diff --git a/PWParallaxScrollViewExample/ViewController.m b/PWParallaxScrollViewExample/ViewController.m index ddc8e55..11108ac 100755 --- a/PWParallaxScrollViewExample/ViewController.m +++ b/PWParallaxScrollViewExample/ViewController.m @@ -106,6 +106,7 @@ - (void)initControl // _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsZero; _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 100); + _scrollView.showsScrollIndicator = NO; [self.view insertSubview:_scrollView atIndex:0]; } From 5aaa4db0a0c9e937956225ccf64532baab9ce815 Mon Sep 17 00:00:00 2001 From: Irad Ratmansky Date: Tue, 28 Oct 2014 13:29:13 +0200 Subject: [PATCH 4/4] fixing bug: overriding the setFrame method. --- PWParallaxScrollView/PWParallaxScrollView.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PWParallaxScrollView/PWParallaxScrollView.m b/PWParallaxScrollView/PWParallaxScrollView.m index 0e915f7..e7ccf04 100755 --- a/PWParallaxScrollView/PWParallaxScrollView.m +++ b/PWParallaxScrollView/PWParallaxScrollView.m @@ -50,6 +50,13 @@ - (id)initWithFrame:(CGRect)frame return self; } +-(void)setFrame:(CGRect)frame{ + [super setFrame:frame]; + _touchScrollView.frame = self.bounds; + _foregroundScrollView.frame = self.bounds; + _backgroundScrollView.frame = self.bounds; +} + - (void)setDataSource:(id)dataSource { _dataSource = dataSource;