All Projects → Nodlik → Stpageflip

Nodlik / Stpageflip

Licence: mit
Simple library for creating realistic page turning effects

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Stpageflip

Nodebook
📖 Livre publié aux Éditions Eyrolles • Première édition : Node.js v10 et npm v6.
Stars: ✭ 286 (+95.89%)
Mutual labels:  book, frontend
Unitybookpagecurl
Page curl effect for Unity3d using UGUI
Stars: ✭ 464 (+217.81%)
Mutual labels:  book, page
Aofe.code
《前端架构:从入门到微前端》源码,code for Architecture of Frontend
Stars: ✭ 292 (+100%)
Mutual labels:  book, frontend
Zhuishushenqi
追书神器Swift版客户端(非官方)。 不断更新中......
Stars: ✭ 196 (+34.25%)
Mutual labels:  reader, book
Frontend Mentor Challenge
Here you will find all the challenges that we took from frontend-mentor.
Stars: ✭ 47 (-67.81%)
Mutual labels:  page, frontend
Choo Handbook
🚂✋📖 - Learn the choo framework through a set of exercises
Stars: ✭ 266 (+82.19%)
Mutual labels:  book, frontend
Front End Handbook 2019
[Book] 2019 edition of our front-end development handbook
Stars: ✭ 3,964 (+2615.07%)
Mutual labels:  book, frontend
Fe
前端热门文章阅读
Stars: ✭ 174 (+19.18%)
Mutual labels:  book, frontend
Buka
Buka is a modern software that helps you manage your ebook at ease.
Stars: ✭ 896 (+513.7%)
Mutual labels:  reader, book
Koodo Reader
A modern ebook manager and reader with sync and backup capacities for Windows, macOS, Linux and Web
Stars: ✭ 2,938 (+1912.33%)
Mutual labels:  reader, book
Owllook
owllook-小说搜索引擎
Stars: ✭ 2,163 (+1381.51%)
Mutual labels:  reader, book
Novelreader
仿照"任阅"的追书、看书的小说阅读器。重写"任阅"的代码,优化代码逻辑和代码结构,降低内存使用率。重写小说阅读器,支持网络阅读、本地阅读(支持分章,虚拟分章)。支持仿真翻页、上下滚动翻页等翻页效果。支持小说断点续传功能。优化用户使用体验。
Stars: ✭ 1,325 (+807.53%)
Mutual labels:  reader, book
Growth In Action
全栈增长工程师实战
Stars: ✭ 2,411 (+1551.37%)
Mutual labels:  book, frontend
Friendbook
📕 "友书" 小说阅读app
Stars: ✭ 275 (+88.36%)
Mutual labels:  reader, book
Webpack Book
From apprentice to master (CC BY-NC-ND)
Stars: ✭ 2,372 (+1524.66%)
Mutual labels:  book, frontend
Simplereader
参考"任阅" 网络小说阅读器,一款ReactNative小说阅读器
Stars: ✭ 351 (+140.41%)
Mutual labels:  reader, book
React Landing Page Template
A simple react one page landing page templates for startups/companies
Stars: ✭ 224 (+53.42%)
Mutual labels:  page, frontend
Oho Reader
【停止维护】哦豁阅读器!API源自追书神器,免费使用!填坑完成!使用react
Stars: ✭ 571 (+291.1%)
Mutual labels:  reader, book
Reader
📕一款在任阅基础上改进的网络小说阅读器,采用Kt编写,支持听书,仿真翻页,插页图片等。欢迎 star or fork!
Stars: ✭ 94 (-35.62%)
Mutual labels:  reader, book
Fe note
📒 Front-end Development Notebook From Start to Finish! (Simplified Chinese)
Stars: ✭ 1,534 (+950.68%)
Mutual labels:  book, frontend

GitHub license npm npm

StPageFlip

Powerful, simple, and flexible JS Library for creating realistic and beautiful page turning effect.

Features

  • 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

Demo and docs: https://nodlik.github.io/StPageFlip/

For React.JS you can use: https://nodlik.github.io/react-pageflip/

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

Installation

You can install the latest version using npm:

npm install page-flip

Or download bundle from Github

Usage

If you've installed the package from npm, you should import PageFlip from page-flip package, or just use <script/> tag:

<script src="{path/to/scripts}/page-flip.browser.js"></script>

To create a new PageFlip object:

import { PageFlip } from 'page-flip';

const pageFlip = new PageFlip(htmlParentElement, settings);

// or if you're using a script tag and page-flip.browser.js:
const pageFlip = new St.PageFlip(htmlParentElement, settings);

htmlParentElement - HTMLElement- root element, where the book will be created

settings: object - configuration object.

To draw on a canvas, use loadFromImages:

pageFlip.loadFromImages(['path/to/image1.jpg', 'path/to/image2.jpg' ... ]);

To load page from html elements - use loadFromHtml:

pageFlip.loadFromHtml(items);

For example:

<div id="book">
    <div class="my-page" data-density="hard">
        Page Cover
    </div>
    <div class="my-page">
        Page one
    </div>
    <div class="my-page">
        Page two
    </div>
    <div class="my-page">
        Page three
    </div>
    <div class="my-page">
        Page four
    </div>
    <div class="my-page" data-density="hard">
        Last page
    </div>
</div>
const pageFlip = new PageFlip(document.getElementById('book'), {
    width: 400, // required parameter - base page width
    height: 600, // required parameter - base page height
});

pageFlip.loadFromHTML(document.querySelectorAll('.my-page'));

Use data-density="hard" attribute to specify page type (soft | hard) and define flipping animation.

Config

To set configuration define these parameters when creating an object:

  • 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. !This mode uses cloning of html elements (pages)
  • startZIndex: number - default: 0 Initial value to z-index
  • startPage: number - default: 0 Page number from which to start viewing
  • 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 (new on 1.1.0)
  • clickEventForward: boolean - default: true forwarding click events to the page children html elements (only for a and button tags) (new on 1.1.0)
  • useMouseEvents: boolean - default: true using mouse and touch events to page flipping (new on 1.2.0)
  • disableFlipByClick: boolean - default: false if this value is true, flipping by clicking on the whole book will be locked. Clicking will only work in corners (new on 2.0.3)

Events

To listen events use the method on:

pageFlip.on('flip', (e) => {
    // callback code
    alert(e.data); // current page number
});

Available events:

  • flip: number - triggered by page turning
  • changeOrientation: ("portrait", "landscape") - triggered when page orientation changes
  • changeState: ("user_fold", "fold_corner", "flipping", "read") - triggered when the state of the book changes
  • init: ({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
  • update: ({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

  • getPageCount: number - Get number of all pages
  • getOrientation: 'portrait', 'landscape' - Get the current orientation: portrait or landscape
  • getBoundsRect: PageRect - Get current book sizes and position
  • getCurrentPageIndex: number - Get the current page number (starts at 0)
  • turnToPage(pageNum: number) - Turn to the specified page number (without animation)
  • turnToNextPage() - Turn to the next page (without animation)
  • turnToPrevPage() - Turn to the previous page (without animation)
  • flipNext(corner: 'top' | 'bottom') - Turn to the next page (with animation)
  • flipPrev(corner: 'top' | 'bottom') - Turn to the previous page (with animation)
  • flip(pageNum: number, corner: 'top' | 'bottom') - Turn to the specified page (with animation)
  • loadFromImages(images: ['path-to-image1.jpg', ...]) - Load page from images
  • loadFromHtml(items: NodeListOf | HTMLElement[]) - Load page from html elements
  • updateFromHtml(items: NodeListOf | HTMLElement[]) - Update page from html elements (new on 0.4.0)
  • updateFromImages(images: ['path-to-image1.jpg', ...]) - Update page from images (new on 0.4.0)
  • destroy() - Destructor. Remove a root HTML element and all event handlers (new on 0.4.0)

Contacts

Oleg,

[email protected]

https://github.com/Nodlik/StPageFlip

Buy me a coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].