Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
flipbook-viewer
Advanced tools
Amazing Page Flip Animation for a (PDF/Image Collection) Flipbook viewer
Amazing flip book component with animated pages.
This is a tiny library that can show flip books from any source (including PDF’s, images, etc).
Below shows the flip book
on the given div
with the id div-id
:
'use strict'
import { init as flipbook } from 'flipbook-viewer';
...
flipbook(book, 'div-id', (err, viewer) => {
if(err) console.error(err);
console.log('Number of pages: ' + viewer.page_count);
viewer.on('seen', n => console.log('page number: ' + n));
next.onclick = () => viewer.flip_forward();
prev.onclick = () => viewer.flip_back();
zoom.onclick = () => viewer.zoom();
});
The viewer can show any flip book. All you need to do is provide a book interface:
{
numPages: () => {
/* return number of pages */
},
getPage: (num, cb) => {
/* return page number 'num'
* in the callback 'cb'
* as any CanvasImageSource:
* (CSSImageValue, HTMLImageElement,
* SVGImageElement, HTMLVideoElement,
* HTMLCanvasElement, ImageBitmap,
* OffscreenCanvas)
*/
}
}
An optional opts
parameter can be passed in to change the UI:
const opts = {
backgroundColor: "#353535",
boxColor: "#353535",
width: 800,
height: 600,
}
flipbook(book, 'div-id', opts, (err, viewer) => ...
You can listen on the viewer
for which pages were seen:
viewer.on('seen', n => ...)
The returned viewer can be used to programmatically control the viewer:
viewer.flip_forward()
viewer.flip_back()
viewer.zoom()
Finally, sometimes it makes sense to just show the book as a simple, scrollable view. To pass in only a singlepage:true
option:
flipbook(book, 'div-id', {singlepage:true}, (err, viewer) => ...
This will generate a series of canvases with class="flipbook__page"
and id="flipbook__pgnum_<n>"
that you can style using CSS. The single page view will raise the same seen
event that the flipbook viewer does for tracking which pages the user actually flips through.
The single page viewer is currently experimental and very simple. It should work for many PDF's but is not optimized for handling PDF's with a large number of pages.
Enjoy!
FAQs
Amazing Page Flip Animation for a (PDF/Image Collection) Flipbook viewer
The npm package flipbook-viewer receives a total of 59 weekly downloads. As such, flipbook-viewer popularity was classified as not popular.
We found that flipbook-viewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.