
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@ridi/react-webviewer
Advanced tools
http://www.ridicorp.com/react-webviewer/demo/
npm install @ridi/react-webviewer
Add @ridi/react-webviewer
reducer into your reducers.
import { reducers as viewerScreen } from '@ridi/react-webviewer';
import { combineReducers } from 'redux';
const appReducer = combineReducers({
...
viewerScreen,
...
});
Connect ViewerHelper
, PageCalculator
, ReadPositionHelper
with redux store.
import { createStore } from 'redux';
import { ViewerHelper, PageCalculator, ReadPositionHelper } from '@ridi/react-webviewer';
const store = createStore( ... );
ViewerHelper.connect(store, { ...options });
PageCalculator.connect(store, { ...options });
ReadPositionHelper.connect(store);
ViewerHelper
's options = defaults:
paddingVertical
= DEFAULT_PADDING_VERTICAL(35
),pageMaxWidth
= PAGE_MAX_WIDTH(700
),pageViewerSelector
= PAGE_VIEWER_SELECTOR(#viewer_contents .pages
),extendedTouchWidth
= EXTENDED_TOUCH_WIDTH(100
),PageCalculator
's options = defaults:
containExtraPage
= 1ViewerScreen
ComponentViewerScreen
component provides all functionality of viewer and renders viewer body.
Put ViewerScreen
component into your component.
import React from 'react';
import ViewerScreen from '@ridi/react-webviewer';
export default ViewerPage extends React.Component {
render() {
return <ViewerScreen />;
}
};
ViewerScreen
's properties:
onMount
(func): called after viewer is mountedonUnmount
(func): called after viewer is unmountedonMoveWrongDirection
(func): called when user try to tap wrong direction to the next page (on page
viewerType)footer
(node): markup for the footer areafontDomain
(string): prefixed URL for searching font filesignoreScroll
(bool): temporarily disable scrolling (on scroll
viewerType)disablePageCalculation
(bool): temporarily disable page calculation (on page
viewerType)You can extend or replace child components of ViewerScreen
with the HoC-style function createStyledViewerScreen()
.
// Signature
createStyledViewerScreen = ({
TouchableScrollScreen = ScrollScreen,
StyledScrollContents = ScrollContents,
TouchablePageScreen = PageScreen,
StyledPageContents = PageContents,
SizingWrapper = SizingWrapper,
} = {}) => ViewerScreen
This is an example.
import {
createStyledViewerScreen,
SizingWrapper,
ScrollContents,
PageContents,
ScrollScreen,
PageScreen,
} from '@ridi/react-webviewer';
const TouchableScrollScreen = ScrollScreen.extend`...`;
const TouchablePageScreen = PageScreen.extend`...`;
...
createStyledViewerScreen({
TouchablePageScreen,
TouchableScrollScreen,
...,
})
updateMetaData
renderSpine
or renderImages
updateMetaData
Dispatch updateMetaData
action to update content's metadata.
import {
updateMetaData,
ContentType,
AvailableViewerType,
BindingType,
} from '@ridi/react-webviewer';
const contentType = ContentType.COMIC;
const viewerType = AvailableViewerType.BOTH;
const bindingType = BindingType.LEFT;
dispatch(updateMetaData(contentType, viewerType, bindingType));
viewerType
: available viewer type (BOTH: 0, SCROLL: 1, PAGE: 2)contentType
: content type (WEB_NOVEL: 10, COMIC: 20, WEBTOON: 30)bindingType
: binding type (LEFT: 0, RIGHT: 1)renderSpine
And then dispatch renderSpine
action to render html
into the viewer after loading contents data.
import { renderSpine } from '@ridi/react-webviewer';
...
const index = 0;
const html = '<h1>hello, world</h1>';
dispatch(renderSpine(index, html));
renderImages
If you have image contents to render lazily, dispatch renderImages
instead of renderSpine
.
import { renderImages } from '@ridi/react-webviewer';
...
const images = [{ src: '/image_1.jpg' }, { src: '/image_2.jpg' }, ...];
dispatch(renderImages(images));
$ npm install
$ npm run install:demo
$ npm run watch
Browse http://localhost:8000.
FAQs
React-Redux based comics viewer
The npm package @ridi/react-webviewer receives a total of 2 weekly downloads. As such, @ridi/react-webviewer popularity was classified as not popular.
We found that @ridi/react-webviewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.