baker icon indicating copy to clipboard operation
baker copied to clipboard

Disable tap to swipe

Open morands opened this issue 14 years ago • 9 comments

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

morands avatar Jan 28 '12 10:01 morands

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.

zenz avatar Jan 28 '12 13:01 zenz

GEAT!! Exactly what I was looking for, sorry for issue #281 but I haven't saw that. Thank you so much, @zenz

morands avatar Jan 28 '12 14:01 morands

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. :)

folletto avatar Jan 28 '12 23:01 folletto

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 avatar Jan 29 '12 09:01 morands

@morands , you can put your action elements far from the screen border to avoid that happen.

zenz avatar Jan 29 '12 13:01 zenz

@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 avatar Jan 29 '12 13:01 morands

@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 avatar Jan 29 '12 14:01 zenz

@zenz this can be an idea, I'll try to do this later :)

morands avatar Jan 29 '12 14:01 morands

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.

folletto avatar Feb 14 '12 00:02 folletto