1. Project overview
Flippy is a front-end template that showcases a 3D flipbook viewer with WebGL acceleration, built-in lightbox and drop-zone demos, and Tailwind-friendly styling. The project ships as a static site (no build toolchain required) but includes optional scripts and ES module wrappers so you can integrate it with modern bundlers.
Core technologies
- WebGL rendering for realistic page flips
- jQuery-driven initialization (ES module friendly)
- Tailwind utility classes compiled into
style.css - TouchSwipe for gesture support
- Screenfull for fullscreen toggles
Key capabilities
- Embed demo (in-page viewer)
- Lightbox + preset viewer demo
- Drag-and-drop PDF import
- Theme switcher with persisted preference
- Mobile navigation drawer with focus management
2. System requirements
The documentation uses plain HTML/CSS/JS and can be opened directly in a browser. For local development we recommend:
| Requirement | Recommended version |
|---|---|
| Node.js | >= 18 (only required if you install additional tooling) |
| Modern browser | Chrome 112+, Edge 112+, Safari 16+, Firefox 110+ |
| Hardware | GPU acceleration recommended for smooth WebGL playback |
3. Quick start
-
Install dependencies (optional):
If you plan to use a bundler or run linting, install packages with
npm install. The static demo works without this step. -
Serve the site:
Open
index.htmldirectly or run a static server (for examplenpx serve .) to ensure module imports resolve. -
Load PDFs:
Keep sample PDFs in
/books. Update paths insideindex.jsif you rename or add new files. -
Customize:
Adjust Tailwind classes in
index.htmlor extend utilities instyle.css. Review the customization section for viewer options.
file:// can break module imports in some browsers. Prefer a local HTTP server.4. Project structure
flippy/
├─ books/ # Sample PDFs
├─ docs/ # Documentation (this file)
├─ public/ # Static assets (icons, images)
├─ src/ # ES modules (jQuery, Flippy, helpers)
│ ├─ flippy.js # Core viewer logic
│ ├─ flippy.webgl.js # WebGL rendering engine
│ ├─ flippy.pdfservice.js# PDF.js integration
│ ├─ screenfull.js # Fullscreen helper
│ ├─ touchswipe.js # Gesture support
│ ├─ ... # Additional vendor modules
├─ index.html # Landing page with live demos
├─ index.js # Entry point that wires demos together
├─ style.css # Tailwind compiled stylesheet
└─ package.json # Optional scripts / metadata
5. Available scripts
The template intentionally keeps scripts minimal. Suggested commands:
| Command | Description |
|---|---|
npm install |
Install dependencies if you plan to use tooling (optional). |
npx serve . |
Serve the project over HTTP for local development. |
npx prettier --write "**/*.html" |
Format documentation or additional HTML files. |
6. Live demo widgets
All demos are initialized inside index.js after the core modules finish loading. Each call uses the same flippyBook API with different options.
Embedded viewer
Renders inline within the page, ideal for product tours.
jQuery("#flippyEmbedExample").flippyBook({
pdfUrl: "./books/book.pdf",
textLayer: true
});
Lightbox + preset viewer
jQuery("#flippyLightboxExample").flippyBook({
pdfUrl: "./books/book02.pdf",
textLayer: true,
lightBox: true
});
jQuery("#flippySelectedExample").flippyBook({
pdfUrl: "./books/book02.pdf",
textLayer: true,
lightBox: true
});
Both buttons target the same PDF with slightly different entry points, letting stakeholders compare triggers.
Drop zone demo
jQuery("#flippyDropZoneExample").flippyBook({
textLayer: true,
lightBox: true,
dropZone: {
enabled: true,
statusSelector: ".flippy-dropzone-status"
}
});
The drop zone accepts PDF files, opens them in a lightbox, and updates the status element to indicate success or validation errors.
7. Customization
Viewer options
The flippyBook initializer accepts a single configuration object. Options are additive; unspecified values fall back to sensible defaults.
| Option | Type | Default | Description |
|---|---|---|---|
pdfUrl |
string | null |
Absolute or relative path to the PDF to render. Required unless images is supplied. |
images |
string[] | [] |
Array of image URLs for image-only flipbooks. Overrides pdfUrl when provided. |
lightBox |
boolean | false |
Opens the viewer in a modal lightbox overlay instead of inline. |
textLayer |
boolean | true |
Enables PDF.js selectable text overlay. Disable for image-only catalogs. |
sound |
boolean | true |
Controls page flip audio effects. Toggle off for silent experiences. |
autoPlay |
boolean | false |
Automatically advances pages on load. Often combined with autoPlayInterval. |
autoPlayInterval |
number | 5000 |
Delay in milliseconds between automatic page turns when autoPlay is true. |
pageShadow |
boolean | true |
Toggles dynamic shadows during page turns. Disable for maximum performance. |
scale |
number | 1 |
Global scale multiplier for the viewer canvas. Useful when embedding in smaller containers. |
thumbs |
boolean | true |
Displays the thumbnail sidebar/navigation when supported. |
bookmarks |
boolean | true |
Enables table-of-contents/bookmark sidebar from PDF outline metadata. |
dropZone.enabled |
boolean | false |
Turns the target element into a drag-and-drop area for local PDFs. |
dropZone.statusSelector |
string | null |
CSS selector used to display drop-zone status and errors. |
callbacks.onReady |
function | () => {} |
Invoked when the viewer has finished initializing. |
callbacks.onPageChange |
function | (page) => {} |
Fires whenever the current page changes, receiving the new page index. |
callbacks.onError |
function | (error) => console.error(error) |
Called when the viewer encounters an unrecoverable error (missing PDF, parsing error, etc.). |
Sample configuration
$("#marketingLookbook").flippyBook({
pdfUrl: "/media/lookbook.pdf",
lightBox: false,
textLayer: true,
pageShadow: false,
autoPlay: true,
autoPlayInterval: 7000,
dropZone: {
enabled: false
},
callbacks: {
onReady: () => console.log("Viewer ready"),
onPageChange: (page) => analytics.track("flipbook:page", { page })
}
});
Common tweaks
- Swap PDFs by updating
pdfUrl. - Disable text selection (
textLayer: false) for performance on graphics-heavy catalogs. - Customize toolbar icons inside
src/flippy.js(search for toolbar template strings). - Override lightbox backdrop styles via
.flippy-lightboxinstyle.css.
8. Branding & theming
All styling is Tailwind-compatible. To adjust colors globally, edit Tailwind variables in style.css or replace utility classes in index.html.
Dark mode persistence
The theme toggle writes the user choice to localStorage under the key flippy-theme. To change the default theme, update the inline script in index.html.
Gradient sections
Hero and drop-zone sections use layered gradient backgrounds defined directly in the markup. Adjust gradient colors to match your brand palette.
9. Embedding Flippy elsewhere
To embed the viewer into another project:
- Copy the contents of
src/,books/,style.css, and the relevant HTML snippet. - Ensure
jquery.module.js(or your own jQuery entry) is available. - Call
flippyBookon your target element after the DOM is ready.
<link rel="stylesheet" href="/path/to/style.css" />
<div id="myFlipbook"></div>
<script type="module">
import $ from "/path/to/jquery.module.js";
import "/path/to/flippy.js";
import "/path/to/flippy.webgl.js";
// ...other modules
$("#myFlipbook").flippyBook({
pdfUrl: "/documents/proposal.pdf",
lightBox: false,
textLayer: true
});
</script>
10. Analytics & events
The base project does not ship analytics, but Flippy exposes callbacks via jQuery events:
flippy:pageChange— Fired with the new page index.flippy:ready— Fired once the viewer is initialized.flippy:lightbox:open/flippy:lightbox:close— Monitor modal sessions.
$("#flippyEmbedExample").on("flippy:pageChange", (_, page) => {
console.log("User navigated to page", page);
});
11. Monetization patterns
Flippy does not prescribe a payment provider but supports common patterns:
- Paywall gate: Hide the viewer until an authenticated flag returns true.
- CTA overlays: Inject custom buttons using
flippy:readyand DOM overlays. - Ad placements: Reserve regions around the viewer or add top/bottom banners inside the lightbox container.
12. Accessibility
- All interactive controls use buttons and links with focus styles inherited from Tailwind.
- Lightbox trap: focus returns to the trigger when closed.
- Drop zone includes
role="button"andtabindex="0"for keyboard usage. - Ensure alternative PDFs include selectable text for screen readers (avoid image-only scans when possible).
13. Performance tips
- Optimize PDFs (compress images, remove unused fonts).
- Preload frequently accessed PDFs via
<link rel="preload">. - Disable
textLayerfor image-only catalogs to reduce DOM load. - Test on mid-range hardware to gauge GPU performance.
14. Troubleshooting
Error: require is not defined
Legacy plugins expect CommonJS. The project shims require in index.js. Ensure you serve the ES module bundle and do not remove the shim block.
PDF fails to load
- Check console for CORS errors (serve via HTTP, not
file://). - Verify the
pdfUrlpath and file extension. - Validate that the PDF is not password-protected (Flippy cannot unlock protected files).
Slow performance
- Reduce page count in the PDF or split into multiple volumes.
- Disable shadows or reduce quality inside
flippy.webgl.jsif you customize the renderer.
15. Frequently asked questions
Can I load images instead of PDFs?
Yes. Provide an array of image URLs via the Flippy configuration (see flippy.js docs inside the source for images mode).
Does Flippy support mobile?
TouchSwipe powers gesture controls, and the layout is responsive. Always test on real devices to confirm performance.
How do I change icons?
Icons are loaded from /icons/unicon-*.css. Replace with your preferred icon font and update classes in the HTML or Flippy templates.
16. Support & next steps
If you extend the project:
- Create reusable components for repeated sections (Hero, Demos, Capabilities).
- Add automated tests around drop-zone validation if you integrate uploads server-side.
- Consider bundling with Vite or Next.js if you need advanced routing or data fetching.