fedefrappi / AePubReader

Another ePub Reader for iPad
-
369 stars 150 forks source link

Page Curl #3

Open mineshpurohit opened 12 years ago

mineshpurohit commented 12 years ago

Is there an option for page curl, instead of slide?

Thank you.

fedefrappi commented 12 years ago

Hi, unfortunately there is no such option at the moment and its implementation wouldn't be straightforward

ssutee commented 12 years ago

I'm working on this issue.

It can be done by using UIPageViewController (iOS 5).

But the model that has to be used for UIPageViewController is quite different from the one that AePubReader uses.

zeroCoder1 commented 12 years ago

I am commenting on a 3 month old post, anyway

@mineshpurohit if you see this piece of code: https://github.com/zeroCoder1/Epub-Reader/blob/master/testPubb/testPubb/ViewController.m#L207

I have managed to put in a page curl, may be you can try some similar stuff. I don't know if I am right, but I managed to do it like this.

If you are satisfied with the answer you can close the issue. If you have found a better way to do it, you can share it with us too. It will be useful

Cheers.

vikysaran commented 10 years ago

Page curl was done in one of closed topics. Just replace these three methods- - (void) gotoNextSpine - (void) gotoNextPage - (void) gotoPrevPage with given below:

- (void) gotoNextSpine {
    if(!paginating){
        if(currentSpineIndex+1<[loadedEpub.spineArray count]){
            [self loadSpine:++currentSpineIndex atPageIndex:0];

            CATransition *transition = [CATransition animation];
            [transition setDelegate:self];
            [transition setDuration:0.5f];
            [transition setType:@"pageCurl"];
            [transition setSubtype:@"fromRight"];
            [self.webView.layer addAnimation:transition forKey:@"CurlAnim"];
        }
    }
}

- (void) gotoNextPage
{
    if(!paginating)
    {
        if(currentPageInSpineIndex+1<pagesInCurrentSpineCount)
        {
            [self gotoPageInCurrentSpine:++currentPageInSpineIndex];
            CATransition *transition = [CATransition animation];
            [transition setDelegate:self];
            [transition setDuration:0.5f];
            [transition setType:@"pageCurl"];
            [transition setSubtype:@"fromRight"];
            [self.webView.layer addAnimation:transition forKey:@"CurlAnim"];
        }
        else
        {
            [self gotoNextSpine];
        }
    }
}

- (void) gotoPrevPage
{
    if (!paginating)
    { if(currentPageInSpineIndex-1>=0)
    {
        [self gotoPageInCurrentSpine:--currentPageInSpineIndex];
        CATransition *transition = [CATransition animation];
        [transition setDelegate:self];
        [transition setDuration:0.5f];
        [transition setType:@"pageUnCurl"];
        [transition setSubtype:@"fromRight"];
        [self.webView.layer addAnimation:transition forKey:@"UnCurlAnim"];
    }
        else
        {
            if(currentSpineIndex!=0)
            {
                CATransition *transition = [CATransition animation];
                [transition setDelegate:self];
                [transition setDuration:0.5f];
                [transition setType:@"pageUnCurl"];
                [transition setSubtype:@"fromRight"];
                [self.webView.layer addAnimation:transition forKey:@"UnCurlAnim"];
                int targetPage = [[loadedEpub.spineArray objectAtIndex:(currentSpineIndex-1)] pageCount];
                [self loadSpine:--currentSpineIndex atPageIndex:targetPage-1];
            }
        }
    }
}