A React.js implementation of the Flipboard page swipe

Jul 09, 2018
A React.js implementation of the Flipboard page swipe


DISCLAIMER: This package is in no way related to nor endorsed by Flipboard, Inc. nor flipboard.com. This is just a showcase of HTML5 & CSS3 effect implemented with React.

This package allows you to use the cool Flipboard page swipe effect in your React.js apps.

View demo Download Source

It has a responsive option, so you can possibly cover your entire page with it!



Installation is pretty straight-forward, as you just have to npm install this package:

npm install --save react-flip-page

Then, you can require the module with any way you like, let it be webpack or something else.


This package consists of one single component that does all the work. Simply throw a FlipPage component with some children that will be the content.

<FlipPage> <article> <h1>My awesome first article</h1> <p>My awesome first content</p> </article> <article> <h1>My wonderful second article</h1> <p>My wonderful second content</p> </article> <article> <h1>My excellent third article</h1> <p>My excellent third content</p> </article> </FlipPage>


There are a few properties that define the behaviour of the component, here they are:

orientationstringverticalOrientation of swipes. vertical or horizontal for respectively up/down swipes and left/right swipes
uncutPagesbooleanfalseIf true, the pages will be allowed to overflow through the container. The original effect is to keep everything inside the container, but you can set this to true to have a more "bookish" effect.
animationDurationnumber200Duration in ms of the fold/unfold animation
tresholdnumber10Distance in px to swipe before the gesture is activated
maxAnglenumber45Angle of the page when there's nothing to display before/after
maskOpacitynumber0.4Opacity of the masks that covers the underneath content
perspectivestring130emPerspective value of the page fold effect. The bigger, the less noticeable
pageBackgroundstring#fffBackground of the pages. This can be overriden in individual pages by styling the component
firstComponentelementnullComponent that will be displayed under the first page
lastComponentelementnullComponent that will be displayed under the last page
showHintboolfalseIndicates if the component must hint the user on how it works. Setting this to true will lift the bottom of the page 1s after the component is mounted, for 1s
showSwipeHintboolfalseIndicates if the component must hint the user on how it works. Setting this to true will show an example of gesture to switch pages
showTouchHintboolfalseIndicates if the component must hint the user on how it works. Setting this to true will show a pointer indicating where to click to switch pages. Works with
styleobject{}Additional style for the flipboard
heightnumber480Height for the flipboard
widthnumber320Width for the flipboard
onPageChangefunctionCallback when the page has been changed. Parameters: pageIndex, direction
onStartSwipingfunctionCallback when the user starts swiping
onStopSwipingfunctionCallback when the user stops swiping
classNamestring''Optional CSS class to be applied on the container
loopForeverbooleanfalseIf true flipping after the last page will return to the first (and visa-versa)
flipOnTouchbooleanfalseIf true, the user can flip pages by touching/clicking a top/bottom or left/right zone. These zones have CSS classes: rfp-touchZone, rfp-touchZone-previous and rfp-touchZone-next so that you can style them
flipOnTouchZonenumber210Percentage of dimensions of the zone to touch/click to flip pages
disableSwipebooleanfalseIf true, users can't use the swipe feature to switch pages while flipOnTouch is enabled. Make sure you enable flipOnTouch so they can switch pages, or provide buttons binded to Methods
responsivebooleanfalseIf true, the component will be responsive, meaning it will take all the available space. Place the component in a container before to make sure it is visible
startAtnumber0Default start position of the component


There are currently three methods that can be called on the component. To call them, you can use the
ref attribute in React:

<FlipPage ref={(component) => { this.flipPage = component; }}> ... </FlipPage> this.flipPage.gotoPreviousPage();


This method triggers the effect and switches to the previous page, if possible.


This method triggers the effect and switches to the next page, if possible.


This methods positions the component to the wanted page index. The page argument should be between 0 and the number of pages. If not, a RangeError will be thrown. Also note that this does not call the onPageChange callback.