1.2.14 • Published 4 months ago

react-native-mobile-page-flipper v1.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Forked from https://github.com/chris24elias/react-native-page-flipper to remove expo dependency and add new features like text paging

This package allows you to use a cool page curl effect on your React Native apps, it works on Android, iOS.

Installation

yarn add react-native-mobile-page-flipper

In order for this package to work properly, its built using react-native-gesture-handler,react-native-linear-gradient, and react-native-reanimated. So make sure you also have these installed,

yarn add react-native-gesture-handler react-native-linear-gradient react-native-reanimated

Notes: react-native-linear-gradient is used for the shadows on iOS and Android. in order to avoid page flickering with images, use react-native-fast-image as your image component, and preload the image files or use defaultSource instead of source when providing images

Landscape

Jul-18-2022 13-58-29

Landscape w/ singleImageMode

Jul-18-2022 13-59-32

Portrait

Usage

import PageFlipper from 'react-native-page-flipper';

const App = () => {
    return (
      <PageFlipper
        type="image"
        data={[
            'https://up.mangadudes.com/bleach/18/bleach-9337-e60a76a126bc6ecd3211aeaad51a7dba.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9338-89fcdb98b22c94781ba2846ea2e562c3.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9339-5d0e73373eb814d65b18bfa4ca533be8.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9340-c1220292956ae4cc1df0676e2d01c2e1.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9341-159bcbae27446cd1d6c964b4b70af020.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9342-024e1db41ff0ea6e6bc47574b209fda4.jpg',
            'https://up.mangadudes.com/bleach/18/bleach-9344-b14e956a08b6998dd00a61f89db84238.jpg',
        ]}
        pageSize={{
          height: 334, // the size of the images I plan to render (used simply to calculate ratio)
          width: 210,
        }}
        portrait={true}
        renderPage={(data) => <Image source={{ uri: data.content }} style={{ height: '100%', width: '100%' }} />}
      />
    )
}

export default App;

Props

Prop nameTypeDefault valueDescription
type'image' | 'text'undefinedThe type of data you want to render, using text it allows to set max word per page
dataany[] | string[]undefinedThe data you want to render, an array of images, or strings for text urls
firstPageMaxWordsnumberundefinedThe max number of words you want in the first page
maxWordsnumberundefinedThe max number of words you want in other pages
renderPage(page: { index: number; content: string; totalPages: number }) => ElementundefinedThe element to render for each item, with page object you can do conditional rendering based on index
pageSizeObjectundefinedpage size (used only to calculate ratio)
contentContainerStyleObjectundefinedstyle for content container
enabledbooltrueenables / disables the pan gesture handler of the pages
pressablebooltrueenables / disables the tapping on the pages to flip
singleImageModebooltrueDefines whether each page is treated as a single image or two in one. (see above)
renderLastPage() => JSX.Elementundefinedoptional function to render the last page (only applies when not in portrait mode and have an odd number of pages)
portraitboolfalsesets portrait mode (viewing a single page at a time, see above)
onFlippedEndFunctionundefinedCallback for when the page has finished flipping
onFlippedStartFunctionundefinedCallback for when the page has started flipping, (does not trigger when user begins dragging the page, only when manually flipped by tapping the page or calling one of the exposed methods)
onPageDragStartFunctionundefinedCallback for when the page has started dragging (user dragging with finger)
onPageDragFunctionundefinedCallback for when the page is actively being dragged
onPageDragEndFunctionundefinedCallback for when the page has finished dragging
onInitialized((props: { pages: Page[] index: number }) => void)undefinedCallback for when the page flipper is initialized, use page info to set a page indicator for example
renderContainerFunctionundefinedfunction to return an element for rendering the container of the viewer
onEndReachedFunctionundefinedCallback for when the page flipper reaches the last page

Methods

Method nameDescription
goToPageflips to the page index passed in
previousPageflips to the previous page
nextPageflips to the next page
1.2.14

4 months ago

1.2.13

4 months ago

1.2.12

4 months ago

1.2.11

4 months ago

1.2.10

4 months ago

1.2.9

4 months ago

1.2.8

5 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.2.0

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago