Disable tap to swipe
Hi everyone, I'd like to disable the function that when I tap on the left or right part of a page it changes page, I'd like to keep only the swipe. How can I do it?
Thanks in advance, Ed
It was replied with #281, but I like to reply you again as a separate topic.
in RootViewController.m, find this instant method
#pragma mark - GESTURES
- (void)userDidTap:(UITouch *)touch {
CGPoint tapPoint = [touch locationInView:self.view];
NSLog(@"• User tap at [%f, %f]", tapPoint.x, tapPoint.y);
// Swipe or scroll the page.
if (!currentPageIsLocked) {
if (CGRectContainsPoint(upTapArea, tapPoint)) {
NSLog(@" Tap UP /\\!");
[self goUpInPage:@"1004" animating:YES];
} else if (CGRectContainsPoint(downTapArea, tapPoint)) {
NSLog(@" Tap DOWN \\/");
[self goDownInPage:@"1004" animating:YES];
} else if (CGRectContainsPoint(leftTapArea, tapPoint) || CGRectContainsPoint(rightTapArea, tapPoint)) {
int page = 0;
if (CGRectContainsPoint(leftTapArea, tapPoint)) {
NSLog(@" Tap LEFT >>>");
page = currentPageNumber - 1;
} else if (CGRectContainsPoint(rightTapArea, tapPoint)) {
NSLog(@" Tap RIGHT <<<");
page = currentPageNumber + 1;
}
[self changePage:page];
} else if ((touch.tapCount%2) == 0) {
[self toggleStatusBar];
}
}
}
the page = currentPageNumber +1 or -1 is what you need, just remark that line, it will disable the tap side function you want.
GEAT!! Exactly what I was looking for, sorry for issue #281 but I haven't saw that. Thank you so much, @zenz
As I said before, I'd advise you to avoid that if you aren't absolutely sure because users will expect that behaviour. Think twice before disabling it, it might translate to a very bad user experience. :)
Thanks, but I have a bigger problem than that: if I keep active the tap to swipe function when the user tap on the "full screen" or "play" button of a YouTube video also changes page and that would seriously mean a bad user experience ;)
@morands , you can put your action elements far from the screen border to avoid that happen.
@zenz yes I could but this way videos would be smaller and I prefer to have those with 768px width... I can't move the play/full screen buttons in the video player, isn't it?
@morands, maybe you can use javascript to make the video full screen while user hit play button? then your video can placed in any position.just an idea.
@zenz this can be an idea, I'll try to do this later :)
Since this was a too popular request, with the latest commit (f770bb9575aa66bc1ba71ce9786d5418800afd5c) we added a way to disable page turns with both tap, swipe or both.
In book.json now you can use also:
-baker-page-turn-tap
-baker-page-turn-swipe
We also updated the wiki page.