• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

futurepress/epubjs-rn: EpubJS React Native Example

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

futurepress/epubjs-rn

开源软件地址:

https://github.com/futurepress/epubjs-rn

开源编程语言:

JavaScript 86.8%

开源软件介绍:

Epub.js React Native Components

Uses EPUB.js to parse and render epubs on iOS and Android using React Native.

Getting Started

To use the components in your own app install via npm or yarn

npm install --save epubjs-rn

then link the required libraries with

react-native link react-native-static-server && react-native link react-native-webview && react-native link react-native-zip-archive && RNFB_ANDROID_PERMISSIONS=true react-native link rn-fetch-blob && react-native link @lightbase/react-native-orientation && react-native link @react-native-community/async-storage

then require the components you need

import { Epub } from 'epubjs-rn';

Then you can add the reader element in your code:

<Epub src={"https://s3.amazonaws.com/epubjs/books/moby-dick/OPS/package.opf"}
		  flow={"paginated"} />
  • src: the url of your epub to render
  • flow: paginated : scrolled - (default to false, which presents a scrolling view)
  • location: Can be an EPUBCFI, Chapter Url or Spine Position
  • onLocationChange: Function called on every page change, reports current CFI
  • onLocationsReady: Function called once the locations has been generated. Returns the locations object.
  • onViewAdded: Function called once a view has been added to the screen.
  • beforeViewRemoved: Function called before a view will be removed from the screen.
  • width: width (int) of the Epub Rendition
  • height: height (int) of the Epub Rendition
  • onReady: Function called once book has been opened. Returns the book object
  • themes: JSON object of themes names and css properties to be applied
  • theme: Name of the theme to apply, such as light
  • fontSize: CSS override for font size of theme, needs a css unit
  • font: CSS override for font family
  • stylesheet: Link to css stylesheet containing themes
  • script: Url for a javascript file to be injected into the view
  • minSpreadWidth: cut off width for spreads
  • gap: gap (int) between columns / pages
  • onPress: Single tap
  • onDlbPress: double tap on the screen
  • onLongPress: Press and hold
  • onSelected: When the browser selects text

Using a local file server

To unzip compressed epubs locally and use http to stream them to epubjs, you will want to use the Streamer class to manage the files and start a StaticServer.

An example of this method is provided in the example app.

import { Epub, Streamer } from "epubjs-rn";
let streamer = new Streamer();

streamer.start("8899")
	.then((origin) => {
		console.log("Served from:", origin)
		return this.streamer.get("https://s3.amazonaws.com/epubjs/books/moby-dick.epub");
	})
	.then((src) => {
		console.log("Loading from:", src);
		return this.setState({src});
	});

Running the example app

Install with yarn. (Don't use NPM unless you flatten the packages after install)

cd EpubReader/
yarn global add react-native-cli
yarn install 

Then start the iOS or Android App

yarn start
react-native run-ios
react-native run-android

Other

EPUB is a registered trademark of the IDPF.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
raineroviir/react-redux-socketio-chat: Full Stack Chat Application发布时间:2022-03-29
下一篇:
ironhack-labs/lab-thinking-in-react发布时间:2022-03-29
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap