Skip to content

Add Webpack Configuration and index.html for Vanilla JS Setup #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Page Flip Vanilla JS</title>
<style>
#app { width: 800px; height: 600px; border: 1px solid #ccc; margin-bottom: 10px; }
button { margin-right: 5px; }
</style>
</head>
<body>
<div id="app"></div>
<button id="prev">Prev</button>
<button id="next">Next</button>
<button id="zoom">Zoom</button>

<!-- Load the built files -->
<script src="dist/pdf.worker.js"></script>
<script src="dist/flipbook-viewer.js"></script>
<script src="dist/book.pdf.js"></script>
<script>
// Apply to Vanilla JS
const opts = { width: 800, height: 600 };
const app = document.getElementById('app');
const next = document.getElementById('next');
const prev = document.getElementById('prev');
const zoom = document.getElementById('zoom');

// using book.init from book.pdf.js
book.init('sample-local-pdf.pdf', function(err, bookObj) {
if (err) return console.error(err);
flipbook.init(bookObj, app, opts, function(err, viewer) {
if (err) return console.error(err);
viewer.on('seen', n => console.log('page number: ' + n));
next.onclick = () => viewer.flip_forward();
prev.onclick = () => viewer.flip_back();
zoom.onclick = () => viewer.zoom();
});
});
</script>
</body>
</html>
Binary file added sample-local-pdf.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const base = {
},
},
'pdf.worker': 'pdfjs-dist/build/pdf.worker.entry',
'book.pdf': {
import: './test/book-pdf.js',
library: {
name: 'book',
type: 'umd',
umdNamedDefine: true,
},
},
},
output: {
filename: '[name].js',
Expand Down