Coder Social home page Coder Social logo

nodlik / react-pageflip Goto Github PK

View Code? Open in Web Editor NEW
412.0 7.0 84.0 11.55 MB

Simple React.js wrapper for StPageFlip library, for creating realistic and beautiful page turning effect

Home Page: https://nodlik.github.io/react-pageflip/

License: MIT License

JavaScript 10.32% TypeScript 89.68%
reactjs react page flip fold book effects animation javascript

react-pageflip's Introduction

GitHub license npm npm

Version 2.0.0

This version fixed some bugs and is completely written with react hooks. !!! Method access api changed !!!

React.js wrapper for StPageFlip

Simple React.js wrapper for StPageFlip library, for creating realistic and beautiful page turning effect

Features of StPageFlip

  • Works with simple images on canvas and complex HTML blocks
  • Has simple API and flexible configuration
  • Compatible with mobile devices
  • Supports landscape and portrait screen mode
  • Supports soft and hard page types (only in HTML mode)
  • No dependencies

Live Demo with source code: https://nodlik.github.io/react-pageflip/

Docs and examples to StPageFlip: https://nodlik.github.io/StPageFlip/

Docs (generated by TypeDoc): https://nodlik.github.io/StPageFlip/docs/index.html

Installation

You can install the latest version using npm:

npm install react-pageflip

Basic Usage

import HTMLFlipBook from 'react-pageflip';

function MyBook(props) {
    return (
        <HTMLFlipBook width={300} height={500}>
            <div className="demoPage">Page 1</div>
            <div className="demoPage">Page 2</div>
            <div className="demoPage">Page 3</div>
            <div className="demoPage">Page 4</div>
        </HTMLFlipBook>
    );
}

Advanced Usage

You can define pages as a component, but in this case you should use React.forwardRef method. Like this:

const Page = React.forwardRef((props, ref) => {
    return (
        <div className="demoPage" ref={ref}>
            /* ref required */
            <h1>Page Header</h1>
            <p>{props.children}</p>
            <p>Page number: {props.number}</p>
        </div>
    );
});

function MyBook(props) {
    return (
        <HTMLFlipBook width={300} height={500}>
            <Page number="1">Page text</Page>
            <Page number="2">Page text</Page>
            <Page number="3">Page text</Page>
            <Page number="4">Page text</Page>
        </HTMLFlipBook>
    );
}

Props

To set configuration use these props:

  • width: number - required
  • height: number - required
  • size: ("fixed", "stretch") - default: "fixed" Whether the book will be stretched under the parent element or not
  • minWidth, maxWidth, minHeight, maxHeight: number You must set threshold values ​​with size: "stretch"
  • drawShadow: bool - default: true Draw shadows or not when page flipping
  • flippingTime: number (milliseconds) - default: 1000 Flipping animation time
  • usePortrait: bool - default: true Enable switching to portrait mode
  • startZIndex: number - default: 0 Initial value to z-index
  • autoSize: bool - default: true If this value is true, the parent element will be equal to the size of the book
  • maxShadowOpacity: number [0..1] - default: 1 Shadow intensity (1: max intensity, 0: hidden shadows)
  • showCover: boolean - default: false If this value is true, the first and the last pages will be marked as hard and will be shown in single page mode
  • mobileScrollSupport: boolean - default: true disable content scrolling when touching a book on mobile devices
  • swipeDistance: number - default: 30 (px) minimum distance to detect swipe
  • clickEventForward: boolean - default: true forwarding click events to the page children html elements (only for a and button tags)
  • useMouseEvents: boolean - default: true using mouse and touch events to page flipping
  • renderOnlyPageLengthChange: boolean - default: false (NEW on 2.0.0) if this flag is active, the book will be updated and re-rendered ONLY if the number of pages has changed

Events

You can use the following events:

...
function DemoBook() {
    const onFlip = useCallback((e) => {
        console.log('Current page: ' + e.data);
    }, []);

    return (
        <HTMLFlipBook
            /* props */
            onFlip={onFlip}
        >
        /* ... pages */
        </HTMLFlipBook>
    )
}

Available events:

  • onFlip: number - triggered by page turning
  • onChangeOrientation: ("portrait", "landscape") - triggered when page orientation changes
  • onChangeState: ("user_fold", "fold_corner", "flipping", "read") - triggered when the state of the book changes
  • onInit: ({page: number, mode: 'portrait', 'landscape'}) - triggered when the book is init and the start page is loaded. Listen (on) this event before using the "loadFrom..." methods
  • onUpdate: ({page: number, mode: 'portrait', 'landscape'}) - triggered when the book pages are updated (using the "updateFrom..." methods)

Event object has two fields: data: number | string and object: PageFlip

Methods

To use methods, you need to get a PageFlip object. This can be done using React ref and pageFlip(): PageFlip method For example - flipping to the next page:

  function DemoBook() {
        const book = useRef();

        return (
            <>
                <button onClick={() =>
                    book.current.pageFlip().flipNext()}>Next page</button>

                <HTMLFlipBook
                    ...
                    ref={book}
                    ...
                >
                    /* ... pages */
                </HTMLFlipBook>
            </>
        )
  }

Available methods:

Method name Parameters Return type Description
getPageCount number Get number of all pages
getCurrentPageIndex number Get the current page number (starts at 0)
getOrientation 'portrait', 'landscape' Get the current orientation: portrait or landscape
getBoundsRect PageRect Get current book sizes and position
turnToPage pageNum: number void Turn to the specified page number (without animation)
turnToNextPage void Turn to the next page (without animation)
turnToPrevPage void Turn to the previous page (without animation)
flipNext corner: ['top', 'bottom'] void Turn to the next page (with animation)
flipPrev corner: ['top', 'bottom'] void Turn to the previous page (with animation)
flip pageNum: number, corner: ['top', 'bottom'] void Turn to the specified page (with animation)
loadFromImages images: ['path-to-image1.jpg', ...] void Load page from images
loadFromHtml items: NodeListOf, HTMLElement[] void Load page from html elements
updateFromHtml items: NodeListOf, HTMLElement[] void Update page from html elements
updateFromImages images: ['path-to-image1.jpg', ...] void Update page from images
destroy void Destructor. Removes Parent HTML Element and all event handlers

Contacts

Oleg,

[email protected]

https://github.com/Nodlik/react-pageflip

Buy me a coffee

react-pageflip's People

Contributors

nodlik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-pageflip's Issues

The shadows not draw when page flipping

The shadows work fine in first render , but after i setState of anything the shadows then missing . Even I set drawShadow=true but it's still not working.
How can i fix it ?

I got error when tried to build project

1st project got this error:
static/js/main.b6da2208.js from UglifyJs
SyntaxError: Unexpected token: name (e) [./~/page-flip/dist/js/page-flip.browser.js:1,192]

2nd project got this error:
static/js/main.bddfff22.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./~/react-pageflip/build/index.js:10,0]

pageFlip() returning undefined

Running into an issue with using a ref to access the methods.

In the example below, bookRef.current.pageFlip is a function, but calling that function returns undefined - so I cannot access the methods in the way described in the documentation.

Any suggestions?

(PS thanks for the project.. good stuff)

import React, { useState, useRef, useEffect } from 'react';
import HTMLFlipBook from 'react-pageflip';

const App = () => {
  const [currentPageNum, setCurrentPageNum] = useState(0);
  const [totalPages, setTotalPages] = useState(0);
  const bookRef = useRef();

  const onPageTurn = (e) => {
    setCurrentPageNum(e.data);
  }

  useEffect(() => {
    if (bookRef && bookRef.current) {
      setTotalPages(bookRef.current.pageFlip().getPageCount()); // throws error b/c pageFlip() returns undefined!
    }
  }, [bookRef]);

  return (
    <HTMLFlipBook width={300} height={500} ref={bookRef}>
      <div className="demoPage">Page 1</div>
      <div className="demoPage">Page 2</div>
      <div className="demoPage">Page 3</div>
      <div className="demoPage">Page 4</div>
    </HTMLFlipBook>
  );
};

export default App;

Example code doesn't work

When trying to use the example code the following error is thrown:

app.js:66 Uncaught TypeError: this.flipBook.getPageFlip is not a function
    at DemoBook.componentDidMount (app.js:66)
    at commitLifeCycles (react-dom.development.js:20663)
    at commitLayoutEffects (react-dom.development.js:23426)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at commitRootImpl (react-dom.development.js:23151)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at commitRoot (react-dom.development.js:22990)
componentDidMount @ app.js:66
commitLifeCycles @ react-dom.development.js:20663
commitLayoutEffects @ react-dom.development.js:23426
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
commitRootImpl @ react-dom.development.js:23151
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
commitRoot @ react-dom.development.js:22990
performSyncWorkOnRoot @ react-dom.development.js:22329
scheduleUpdateOnFiber @ react-dom.development.js:21881
updateContainer @ react-dom.development.js:25482
(anonymous) @ react-dom.development.js:26021
unbatchedUpdates @ react-dom.development.js:22431
legacyRenderSubtreeIntoContainer @ react-dom.development.js:26020
render @ react-dom.development.js:26103
./assets/app.js @ app.js:124
__webpack_require__ @ bootstrap:19
__webpack_exec__ @ app.css:1
(anonymous) @ app.css:1
__webpack_require__.O @ chunk loaded:23
(anonymous) @ app.css:1
webpackJsonpCallback @ jsonp chunk loading:33
(anonymous) @ app.js:1
react-dom.development.js:20085 The above error occurred in the <DemoBook> component:

    at DemoBook (http://127.0.0.1:8000/build/app.js:279:5)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
logCapturedError @ react-dom.development.js:20085
update.callback @ react-dom.development.js:20118
callCallback @ react-dom.development.js:12318
commitUpdateQueue @ react-dom.development.js:12339
commitLifeCycles @ react-dom.development.js:20736
commitLayoutEffects @ react-dom.development.js:23426
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
commitRootImpl @ react-dom.development.js:23151
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
commitRoot @ react-dom.development.js:22990
performSyncWorkOnRoot @ react-dom.development.js:22329
(anonymous) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
unbatchedUpdates @ react-dom.development.js:22438
legacyRenderSubtreeIntoContainer @ react-dom.development.js:26020
render @ react-dom.development.js:26103
./assets/app.js @ app.js:124
__webpack_require__ @ bootstrap:19
__webpack_exec__ @ app.css:1
(anonymous) @ app.css:1
__webpack_require__.O @ chunk loaded:23
(anonymous) @ app.css:1
webpackJsonpCallback @ jsonp chunk loading:33
(anonymous) @ app.js:1
react-dom.development.js:11340 Uncaught TypeError: this.flipBook.getPageFlip is not a function
    at DemoBook.componentDidMount (app.js:66)
    at commitLifeCycles (react-dom.development.js:20663)
    at commitLayoutEffects (react-dom.development.js:23426)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at commitRootImpl (react-dom.development.js:23151)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at commitRoot (react-dom.development.js:22990)

Missing styles on basic example.

The basic example on your documentation works but without most of the styles. The page turn effect works but missing box-shadows from --left and --right and none of the Sass rules from the stPageFlip demo seem to be there. Would be super useful to include a working example in this main repo, otherwise the wrapper seems to work great !

No dynamic resizing?

It seems like the Flipbook gets its dimensions once on componendDidMount and then never updates (except for Page Refresh) when resizing the Window. So it seems like there is no option to dynamically resize. Am I correct and this is wanted behavior or is it an error on my end?

2.0.3 run error!

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at new c (page-flip.browser.js:1)
    at push../node_modules/page-flip/dist/js/page-flip.browser.js.t.PageFlip.loadFromHTML (page-flip.browser.js:1)
    at index.es.js:75
    at invokePassiveEffectCreate (react-dom.development.js:23487)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at flushPassiveEffectsImpl (react-dom.development.js:23574)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushPassiveEffects (react-dom.development.js:23447)
    at react-dom.development.js:23324
    at workLoop (scheduler.development.js:417)
    at flushWork (scheduler.development.js:390)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157)
c @ page-flip.browser.js:1
loadFromHTML @ page-flip.browser.js:1
(anonymous) @ index.es.js:75
invokePassiveEffectCreate @ react-dom.development.js:23487
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
flushPassiveEffectsImpl @ react-dom.development.js:23574
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushPassiveEffects @ react-dom.development.js:23447
(anonymous) @ react-dom.development.js:23324
workLoop @ scheduler.development.js:417
flushWork @ scheduler.development.js:390
performWorkUntilDeadline @ scheduler.development.js:157
index.js:1 The above error occurred in the <ForwardRef> component:

    at http://localhost:8000/p__User__FlipBook__index.6b55540e.async.js:32:80
    at FlipBook (http://localhost:8000/p__User__FlipBook__index.6b55540e.async.js:173:39)
    at DynamicComponent (http://localhost:8000/umi.js:14555:38)
    at Route (http://localhost:8000/umi.js:90926:29)
    at RouteWithProps (http://localhost:8000/umi.js:104759:19)
    at Switch (http://localhost:8000/umi.js:91132:29)
    at div
    at div
    at main
    at Basic (http://localhost:8000/vendors.731e5b5c.async.js:524:25)
    at Adapter (http://localhost:8000/vendors.731e5b5c.async.js:507:79)
    at section
    at BasicLayout (http://localhost:8000/vendors.731e5b5c.async.js:539:76)
    at Adapter (http://localhost:8000/vendors.731e5b5c.async.js:507:79)
    at BasicLayout (http://localhost:8000/layouts__BookLayout.6570c824.async.js:108:39)
    at Connect (http://localhost:8000/umi.js:17211:9)
    at DynamicComponent (http://localhost:8000/umi.js:14555:38)
    at Route (http://localhost:8000/umi.js:90926:29)
    at RouteWithProps (http://localhost:8000/umi.js:104759:19)
    at Switch (http://localhost:8000/umi.js:91132:29)
    at Router (http://localhost:8000/umi.js:90557:30)
    at ConnectedRouter (http://localhost:8000/umi.js:70005:5)
    at sfc (http://localhost:8000/umi.js:110194:41)
    at IntlProvider (http://localhost:8000/umi.js:97030:5)
    at FormProvider (http://localhost:8000/umi.js:38313:31)
    at LocaleProvider (http://localhost:8000/umi.js:7140:94)
    at ProviderChildren (http://localhost:8000/umi.js:6429:24)
    at LocaleReceiver (http://localhost:8000/umi.js:6998:94)
    at ConfigProvider (http://localhost:8000/umi.js:6537:13)
    at LocaleWrapper (http://localhost:8000/umi.js:110300:34)
    at RouterWrapper (http://localhost:8000/umi.js:111003:34)
    at Provider (http://localhost:8000/umi.js:17052:7)
    at _DvaContainer (http://localhost:8000/umi.js:110506:34)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
console.<computed> @ index.js:1
logCapturedError @ react-dom.development.js:20085
update.callback @ react-dom.development.js:20118
callCallback @ react-dom.development.js:12318
commitUpdateQueue @ react-dom.development.js:12339
commitLifeCycles @ react-dom.development.js:20736
commitLayoutEffects @ react-dom.development.js:23426
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
commitRootImpl @ react-dom.development.js:23151
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
commitRoot @ react-dom.development.js:22990
performSyncWorkOnRoot @ react-dom.development.js:22329
(anonymous) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
flushPassiveEffectsImpl @ react-dom.development.js:23620
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushPassiveEffects @ react-dom.development.js:23447
(anonymous) @ react-dom.development.js:23324
workLoop @ scheduler.development.js:417
flushWork @ scheduler.development.js:390
performWorkUntilDeadline @ scheduler.development.js:157
scheduler.development.js:171 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at new c (page-flip.browser.js:1)
    at push../node_modules/page-flip/dist/js/page-flip.browser.js.t.PageFlip.loadFromHTML (page-flip.browser.js:1)
    at index.es.js:75
    at invokePassiveEffectCreate (react-dom.development.js:23487)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at flushPassiveEffectsImpl (react-dom.development.js:23574)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushPassiveEffects (react-dom.development.js:23447)
    at react-dom.development.js:23324
    at workLoop (scheduler.development.js:417)
    at flushWork (scheduler.development.js:390)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157)
c @ page-flip.browser.js:1
loadFromHTML @ page-flip.browser.js:1
(anonymous) @ index.es.js:75
invokePassiveEffectCreate @ react-dom.development.js:23487
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
flushPassiveEffectsImpl @ react-dom.development.js:23574
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushPassiveEffects @ react-dom.development.js:23447
(anonymous) @ react-dom.development.js:23324
workLoop @ scheduler.development.js:417
flushWork @ scheduler.development.js:390
performWorkUntilDeadline @ scheduler.development.js:157

Any way to specify glossiness value?

Is there any current way to specify the glossiness value (i.e. on a scale from 0-1, how much gloss there should be/how strong the 'light' shining on the page is)? I was thinking something similar to maxShadowOpacity, but couldn't find anything similar in the props - is there any current hacky way of doing this?

Alternatively, are there plans to add such a prop in the future?

Thanks.

how onChangeOrientation works?

can you explain on how onChangeOrientation and onChangeState function works? What is the key that change orientation and state? Can we change the orientation in <HTMLFlipBook orientation='landscape' state='read'/>? It will be great if you can provide function onChangeOrientation for better understanding :)

First page cover only

Dose anyone know how to make so that the first page is only a cover?

Something like this:
2023-09-13 14_12_21-localhost_8000

I was able to do this with fillers as first and last page but on portrait mode, the first page and last page are invisible
2023-09-13 14_37_32-localhost_8000

I was also trying to add statement so that the filler only shows on desktop
{!isMobile && <Filler />} {children} {!isMobile && <Filler />}

But then I'm getting the error:
React.cloneElement(...): The argument must be a React element, but you passed null.

Nextjs ref is always null

Hi,

I am using dynamic load for the flipbook component.
I tried different ways to get ref working but it is always null.
Need help.

I am using it as client rendering so used this command as well
'use client';
Three different ways to import are given below

`const HTMLFlipBook = dynamic(() => import('react-pageflip'), {
ssr: false,
loading: () => {
setIsFlipPageLoaded(false);
return

....Loading...

;
},
loaded: () => {
console.log("Loaded");
setIsFlipPageLoaded(true);
},
forwardRef: true
});

const ForwardedRefHTMLFlipBook = React.forwardRef((props, ref) => (
<HTMLFlipBook {...props} forwardedRef={ref} />
))

const HTMLFlipBook = Loadable({
loader: () => import('react-pageflip'),
loading: LoadingComponent,
});`

Disable page flip on click for custom pages

In my flip book, I have designed a menu(appendix) to navigate to custom pages. But since the default behavior on click is to navigate to next page, unable to overwrite that. please let me know.

The prop disableFlipByClick={currentPageNum === 3} not working

Virtual and Actual Dom mismatch when un-mounting

Hey simply put I have HtmlFlip book component working but when I navigate away from that page and the component un-mounts I get this error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. Any guidance on how to fix this is much appreciated. I apologize if this is user error.

Each child in a list should have a unique "key" prop error with child components

Hi there,

I'm running into a small error message when using <HTMLFlipBook> containing custom <PageContent> components. When running in the browser, the error of Each child in a list should have a unique "key" prop error with child components but when trying to add a key to the custom components it doesn't seem to work properly.

Is there a better way to do this or am I missing something? I've had to use custom components to make each even/odd page a different format. I'll post a code screenshot below:
Screenshot (45)
Screenshot (44)

flipPrev() Animation gets disaaper

for flipPrev(index) function Animation gets disaaper as its not starting from edge of current object as like for next its start from end edge of current object,
same for flpPrev animation should start from start edge of current visible item.
If anyone can help to get this done,i will be very grateful

Issue with responsiveness.

can you please put an autoCenter functionality in the book?
Because it's not centered when the book is closed. I want the book fully centered on both opening and closing.

I am sure you will solve my problem. I am working on it for 1 month but I can't fix it.

Thank you

soft page animation for cover

When you pass the prop showCovera value of true it defaults to a hardcover. Is there any way to toggle to the soft animation on the cover?

flip() function going to wrong index

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

Unwanted line in Firefox

Chrome & Edge:
image

Firefox Developer Edition:
image

There's a thin line in Firefox. How can I remove it?

Re-rendering HTMLFlipBook based on width

Hello,
Am unable to re-render the HTMLFlipBook dynamically. I want to change width based on zoom. However when I do that the original width passed remains as it were.
<HTMLFlipBook size="fixed" width={width} height={height} minWidth={315} minHeight={407.61} flippingTime={700} onFlip={onFlip} ref={flipBook} useMouseEvents={false} showCover usePortrait={false} mobileScrollSupport={false} >

Lazy Loading Feature

It would be great if we can also implement lazy loading feature when we have huge number of pages. Right now, flipbook component requests all the images at the time of initializing.

Flip corner animation doesn't have same effect as desktop on mobile

I have noticed that when you look at the example the flip corner animation has a nice effect where is shows content on the draggable corner. However, when I download locally and spin mine up I do not get this effect. I just get an opacity swipe when dragging from the corner

All the optional props are required

Hello

I used react-pageflip on my pet project which was written in ReactJS using TypeScript as well and there was one problem regarding props . Documentation says that the only required props for HTMLFlipBook are width and height but in real use it turned out that not only these props are required.

I checked node_modules/react-pageflip and it turned out that a lot of props are required indeed. I provided local solution for my project but I reckon that some changes should happen in original code base that it could correspond to the documentation and not to be confusing.

I can fix the issue if you want me to fix it.

Best regards,
Mark

SwipeDistance on mobile

Problem:
When I try to use the Flipbook on a smartphone, it always flips the page when I touch it even when I just want to scroll (I have made my pages scrollable because of varying heights).

So I am looking for something like swipe-detection or if page-turning can be turned off in mobile screens (I have added additional forward and prev buttons for that).
I think swipeDistance feature on mobile (touch-screen) doesn't work or I am not able to leverage it.

My repo if someone wants to take a look: https://github.com/kdlogan19/Flipbook

Thanks

How can I achieve double-page mode?

I'm using the code, which is in the example.

<HTMLFlipBook width={300} height={500}>
    <div className="Page">Page 1</div>
    <div className="Page">Page 2</div>
    <div className="Page">Page 3</div>
    <div className="Page">Page 4</div>
</HTMLFlipBook>

I don't have a 'showCover' prop (Which means, it defaults to false). But still, the flip-book shows in single-page mode. How can I achieve this?

How to force 1 page only to be rendered on mobile?

I want to make my flipbook a little bit more responsive. Kind of hard to do.
For mobile, ideally I'd want it to just render 1 page instead of two since it's too small if it renders two pages in a small width.

Odd number of images

Day day I am having problem with the last page of the flippage when using Odd number of images in "LoadFromImages"

Flippage.Test.-.Google.Chrome.2022-07-12.16-44-16.mp4

Screenshot 2022-07-12 165024
.
have happen is that when flipping the last page (the second last image) shows again then vanish with the flip is completed

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.