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

No flip animation each page is rendering independantly #54

Open
quteboy opened this issue Apr 24, 2024 · 6 comments
Open

No flip animation each page is rendering independantly #54

quteboy opened this issue Apr 24, 2024 · 6 comments

Comments

@quteboy
Copy link

quteboy commented Apr 24, 2024

i am fetching a list of document from an api and its an array of object each object contains url key with s3 bucket url as value
below code is rendering files but each page and pdf is rendering separately thus making page flip animation not working
i think it is because of pagnumber calculation please provide support

{filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <HTMLFlipBook width={width} height={height}> <Page pageNumber={1} /> </HTMLFlipBook> </Document> ); })}

@quteboy
Copy link
Author

quteboy commented Apr 24, 2024

const Page = React.forwardRef(({ pageNumber }, ref) => { return ( <div ref={ref} data-density="hard"> <ReactPdfPage pageNumber={pageNumber} width={width} /> </div> ); });

@grgicpetar
Copy link

grgicpetar commented Apr 25, 2024

You should be using only one HtmlFlipBook component. Currently you're rendering one HtmlFlipBook component per item in your map function.

Also you should probably use Document (pdf viewer) as a container for one Page.

@quteboy
Copy link
Author

quteboy commented Apr 26, 2024

<HTMLFlipBook width={width} height={height}> {filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <Page pageNumber={1} /> </Document> ); })} </HTMLFlipBook>

like this ?
if not please share correct code

@grgicpetar
Copy link

Yup, like that. Does it work now?

@quteboy
Copy link
Author

quteboy commented May 2, 2024

console errors are cleaned but still rendering every pdf page individually

@quteboy
Copy link
Author

quteboy commented May 2, 2024

{filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <HTMLFlipBook width={width} height={height}> {[...Array(item.numPages)].map((_, pageIndex) => ( <div className="demoPage" key={pageIndex}> <Page pageNumber={pageIndex + 1} width={width} height={height} /> </div> ))} </HTMLFlipBook> </Document> ); })}
here is code that i have updated
Please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants