Nodlik / react-pageflip

Simple React.js wrapper for StPageFlip library, for creating realistic and beautiful page turning effect
https://nodlik.github.io/react-pageflip/
MIT License
476 stars 91 forks source link

flip() function going to wrong index #29

Open Kamalakar-Gavali opened 3 years ago

Kamalakar-Gavali commented 3 years ago

Bascially inside FlipBook i have map array of images, and added on text box to enter index and calling flip(index) but its displaying wrong image. i am using its like slider not ebook beacasue i want same effect which is in this library

nucrasenaa commented 3 years ago

same problem and i try to use turnToPage but its displaying wrong image (only go to first page) too.

cdk0507 commented 1 year ago

I'm having the same problem.

NARARIA03 commented 3 weeks ago

I'm having this problem too. If you use turnToPage(), the project will work as you want, but if you use flip(), you'll be turned over to the page you want, and then back to the previous page + page 1.

useEffect(() => {
    if (bookRef?.current?.pageFlip()?.flip) {
      console.log(`curPage: ${curPage.page}`);
      bookRef.current.pageFlip().flip(curPage.page * 2 - 2);
      console.log(curPage.page * 2 - 2);
    }
  }, [curPage]);

If you change 'flip()' to 'turnToPage()' in the code above, the animation disappears, but the logic operates normally. I'm trying to render a fairy tale book consisting of tree-type data whose ending depends on the user's click. For example, you want to allow books to be turned over in the order of 0 -> 2 -> 4 -> 6 -> 8 -> 10 -> 10 -> 12 -> 14 -> 18 -> 26 -> 34 index.

Do you have any good ideas?

Is there a way to go through the code of the flip() function and correct it yourself?