Giter Club home page Giter Club logo

Comments (4)

Blankeos avatar Blankeos commented on July 26, 2024 3

YO @juncraul guess what? I was able to solve it! 🥳🥳🥳🎉🎉🚀🚀🚀🚀🚀🚀

Portrait Mode Gif (2)

I honestly have no idea how to make a smaller-scale example of this. But this is the rough code and description for this that made it work, so bare with me:

  1. I have a width and height from a state (this might not be necessary for your case but I wanted to have customizable sizes). The width and height comes from the callback resolved when I use react-pdf, which basically refers to the width and height of 1 page (not the book so like the width and height of the paper).
  2. I use that width and height for the parent div of the <HTMLFlipBook />. The parent div has a width * 2 because it has to be big enough for two pages. Also notice how the width used inside HTMLFlipBook's props is not multiplied by 2 because I think width and height only refers to 1 page here, not the book.
  3. I added a border class to the div. (It's weird but THIS WAS SUPER IMPORTANT to make this work).
  4. Add the minHeight: 0, and height: height on the Flip Book. Because for some weird reason the minimum height given to the stf_parent div is like 2x of what it's supposed to be, making the page look tall and centered.
  5. Lastly, add the usePortrait boolean. Attach it to a useState if you want.
  6. Additionally, if you want to make it responsive, just attach it to a library like useMediaQuery and control those states.
<div
  style={{ width: width! * 2, height: height }}
  className="relative bg-primary-100 pointer-events-auto border"
>
  <HTMLFlipBook
    key={`${width}-${height}-${isPortrait}`}
    style={{
      minHeight: 0,
     height: height,
   }}
   usePortrait={isPortrait}
   width={width!}
   height={height!}
   maxShadowOpacity={0.2}
   showCover
   onFlip={onPageFlip}
 >
   {renderedPages}
 </HTMLFlipBook>
</div>

from react-pageflip.

juncraul avatar juncraul commented on July 26, 2024

Looking for an answer for this as well.

from react-pageflip.

SaikiranReddyKudumula avatar SaikiranReddyKudumula commented on July 26, 2024

Hey @Blankeos excellent implementation of react page flip, where can i find the full implementation of this library, is it possible for you to share your full code?

from react-pageflip.

lhaynes96 avatar lhaynes96 commented on July 26, 2024

@Blankeos can you show entire code for this?

from react-pageflip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.