3d-pro-flipbook 1.0.0 β†’ 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,107 @@
1
- # Pro Flipbook JS
1
+ # 3d-pro-flipbook
2
2
 
3
- A professional, lightweight, and responsive 3D PDF Flipbook library for the web.
3
+ A lightweight, professional, and responsive 3D PDF Flipbook library for the web.
4
4
 
5
- ## Features
6
- - πŸ“„ **PDF Support:** Renders PDFs directly into a flipbook.
5
+ ## πŸš€ Features
6
+ - πŸ“„ **PDF Support:** Renders PDFs directly into a realistic 3D flipbook.
7
7
  - πŸ“± **Responsive:** Automatically resizes to fit the container.
8
8
  - 🎨 **Customizable:** Change background colors and branding text.
9
9
  - πŸ–±οΈ **Interactive:** Zoom, Drag to flip, and Mouse Wheel support.
10
+ - πŸ”§ **Universal:** Works with React, Vue, Angular, Svelte, and Vanilla JS.
10
11
 
11
- ## Installation
12
+ ---
12
13
 
13
- You can install the library via NPM:
14
+ ## πŸ“¦ Installation
15
+
16
+ Install the package via NPM:
14
17
 
15
18
  ```bash
16
- npm install pro-flipbook-js
19
+ npm install 3d-pro-flipbook
20
+
21
+ =================================
22
+ 1. InstallationFirst, add the library to your project via your package manager:Bashnpm install 3d-pro-flipbook
23
+ # or
24
+ yarn add 3d-pro-flipbook
25
+ 2. The Universal "Golden Rule"No matter which framework you use, the logic is always the same:Import the class and the CSS.Create a container div with a unique ID (e.g., #my-book).Initialize the book inside your framework's "Mounted" lifecycle hook (this ensures the HTML exists before the code runs).3. Framework Examplesβš›οΈ React / Next.jsSince this library interacts with the DOM (browser), you must use a Client Component and the useEffect hook.components/Flipbook.jsJavaScript'use client'; // Required for Next.js 13+
26
+
27
+ import { useEffect } from 'react';
28
+ import { ProFlipbook } from '3d-pro-flipbook';
29
+ import '3d-pro-flipbook/style.css'; // Import styles
30
+
31
+ export default function Flipbook({ pdfUrl }) {
32
+ useEffect(() => {
33
+ // Init inside useEffect to ensure DOM is ready
34
+ new ProFlipbook('#my-book', pdfUrl, {
35
+ brandText: 'My React Book'
36
+ });
37
+ }, [pdfUrl]);
38
+
39
+ return (
40
+ <div id="my-book" style={{ width: '100%', height: '100vh' }}></div>
41
+ );
42
+ }
43
+ 🟒 Vue.js / NuxtUse the onMounted hook to initialize the library.HTML<script setup>
44
+ import { onMounted } from 'vue';
45
+ import { ProFlipbook } from '3d-pro-flipbook';
46
+ import '3d-pro-flipbook/style.css';
47
+
48
+ const pdfSource = '/book.pdf';
49
+
50
+ onMounted(() => {
51
+ new ProFlipbook('#vue-book', pdfSource, {
52
+ brandText: 'Vue Book',
53
+ backgroundColor: '#333'
54
+ });
55
+ });
56
+ </script>
57
+
58
+ <template>
59
+ <div id="vue-book" style="width: 100%; height: 100vh;"></div>
60
+ </template>
61
+ πŸ”΄ AngularInitialize the library inside the ngAfterViewInit lifecycle method.book.component.tsTypeScriptimport { Component, AfterViewInit } from '@angular/core';
62
+ import { ProFlipbook } from '3d-pro-flipbook';
63
+ // Ensure style.css is added to your angular.json styles array or imported in CSS
64
+
65
+ @Component({
66
+ selector: 'app-book',
67
+ template: '<div id="ng-book" style="width: 100%; height: 100vh;"></div>'
68
+ })
69
+ export class BookComponent implements AfterViewInit {
70
+ ngAfterViewInit() {
71
+ new ProFlipbook('#ng-book', 'assets/book.pdf', {
72
+ brandText: 'Angular Book'
73
+ });
74
+ }
75
+ }
76
+ 🟠 Svelte / SvelteKitUse the onMount function.HTML<script>
77
+ import { onMount } from 'svelte';
78
+ import { ProFlipbook } from '3d-pro-flipbook';
79
+ import '3d-pro-flipbook/style.css';
80
+
81
+ onMount(() => {
82
+ new ProFlipbook('#svelte-book', '/book.pdf', {
83
+ brandText: 'Svelte Book'
84
+ });
85
+ });
86
+ </script>
87
+
88
+ <div id="svelte-book" style="width: 100%; height: 100vh;"></div>
89
+ 🌐 Vanilla HTML (No Framework)If you aren't using a bundler, you can use the CDN links directly.HTML<link rel="stylesheet" href="https://unpkg.com/3d-pro-flipbook@latest/dist/style.css">
90
+
91
+ <div id="book-container" style="width: 100%; height: 100vh;"></div>
92
+
93
+ <script src="https://unpkg.com/3d-pro-flipbook@latest/dist/pro-flipbook.umd.js"></script>
94
+
95
+ <script>
96
+ // Access via the global object 'ProFlipbook.ProFlipbook'
97
+ document.addEventListener('DOMContentLoaded', () => {
98
+ new ProFlipbook.ProFlipbook('#book-container', 'book.pdf', {
99
+ brandText: "My HTML Book"
100
+ });
101
+ });
102
+ </script>
103
+ 4. Configuration OptionsYou can pass an options object as the third argument.OptionTypeDefaultDescriptionbrandTextString"Pro Flipbook"The text shown on the loader and book spine.backgroundColorString"#333"The background color of the viewer area.workerUrlStringCDN Link(Advanced) Custom path to PDF.js worker.JavaScriptnew ProFlipbook('#id', 'file.pdf', {
104
+ brandText: "My Company",
105
+ backgroundColor: "#ff0000"
106
+ });
107
+ ⚠️ Common Issues & Troubleshooting1. "Window is not defined" (Next.js / Nuxt / SSR)This happens because the library tries to access the browser window during Server Side Rendering.Fix: Ensure you are initializing the code inside useEffect (React), onMounted (Vue), or ensure the component is client-side only ('use client').2. "Container not found"The code ran before the HTML div was created.Fix: Double-check your ID matches (#my-book vs id="my-book") and that you are using the correct lifecycle hook (e.g., useEffect with an empty dependency array []).3. PDF CORS ErrorThe PDF fails to load from a remote URL.Fix: If loading a PDF from a different domain (e.g., AWS S3), ensure that server has CORS headers enabled (Access-Control-Allow-Origin: *).