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

sensitivityScale #23

Open
wants to merge 1 commit into
base: master
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
2 changes: 2 additions & 0 deletions Classes/AFKPageFlipper.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef enum {
BOOL animating;

BOOL disabled;
CGFloat sensitivityScale;
}

@property (nonatomic,retain) NSObject <AFKPageFlipperDataSource> *dataSource;
Expand All @@ -57,6 +58,7 @@ typedef enum {
@property (nonatomic, retain) UIPanGestureRecognizer *panRecognizer;

@property (nonatomic,assign) BOOL disabled;
@property (nonatomic,assign) CGFloat sensitivityScale;

- (void) setCurrentPage:(NSInteger) value animated:(BOOL) animated;

Expand Down
12 changes: 11 additions & 1 deletion Classes/AFKPageFlipper.m
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ - (void) setDisabled:(BOOL) value {
}
}

@synthesize sensitivityScale;

- (CGFloat) sensitivityScale {
if (sensitivityScale <= 0) {
sensitivityScale = 1.0;
}
return sensitivityScale;
}

#pragma mark -
#pragma mark Touch management
Expand Down Expand Up @@ -376,6 +384,8 @@ - (void) panned:(UIPanGestureRecognizer *) recognizer {
float translation = [recognizer translationInView:self].x;

float progress = translation / self.bounds.size.width;

progress *= self.sensitivityScale;

if (flipDirection == AFKPageFlipperDirectionLeft) {
progress = MIN(progress, 0);
Expand Down Expand Up @@ -442,7 +452,7 @@ - (void) panned:(UIPanGestureRecognizer *) recognizer {
return;
}

if (fabs((translation + [recognizer velocityInView:self].x / 4) / self.bounds.size.width) > 0.5) {
if (fabs((translation * sensitivityScale + [recognizer velocityInView:self].x / 4) / self.bounds.size.width) > 0.5) {
setNextViewOnCompletion = YES;
[self setFlipProgress:1.0 setDelegate:YES animate:YES];
} else {
Expand Down
1 change: 1 addition & 0 deletions Classes/MainController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (void) loadView {
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

flipper = [[[AFKPageFlipper alloc] initWithFrame:self.view.bounds] autorelease];
flipper.sensitivityScale = 2;
flipper.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
flipper.dataSource = self;

Expand Down