@bagelink/vue 1.15.440 → 1.15.447
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/dist/chunk-Bt6Bclq5.cjs +1 -0
- package/dist/chunk-Fx_iipZ-.js +25 -0
- package/dist/components/FlipBook.vue.d.ts +69 -0
- package/dist/components/FlipBook.vue.d.ts.map +1 -0
- package/dist/components/IframeVue.vue.d.ts.map +1 -1
- package/dist/components/Pagination.vue.d.ts +1 -1
- package/dist/components/Pagination.vue.d.ts.map +1 -1
- package/dist/components/Swiper.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SignaturePad.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/upload.d.ts +6 -1
- package/dist/components/form/inputs/Upload/upload.d.ts.map +1 -1
- package/dist/components/form/inputs/signaturePadSizing.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/form-flow/FormFlowPlayer.vue.d.ts +1 -1
- package/dist/form-flow/FormFlowPlayer.vue.d.ts.map +1 -1
- package/dist/form-flow/structure.d.ts +3 -10
- package/dist/form-flow/structure.d.ts.map +1 -1
- package/dist/index.cjs +154 -154
- package/dist/index.css +1 -1
- package/dist/index.mjs +24961 -24629
- package/dist/page-flip.browser-BXnk8BM6.js +1381 -0
- package/dist/page-flip.browser-ByKQXhqK.cjs +127 -0
- package/dist/pdf-CV7M2d0x.cjs +55 -0
- package/dist/pdf-DuN3_wNN.js +17121 -0
- package/dist/style.css +1 -1
- package/dist/types/page-flip.d.ts +37 -0
- package/package.json +3 -1
- package/src/components/FlipBook.vue +445 -0
- package/src/components/IframeVue.vue +2 -0
- package/src/components/Swiper.vue +23 -7
- package/src/components/form/inputs/SignaturePad.vue +18 -7
- package/src/components/form/inputs/Upload/upload.ts +56 -6
- package/src/components/form/inputs/signaturePadSizing.ts +2 -1
- package/src/components/index.ts +1 -0
- package/src/form-flow/FormFlowPlayer.vue +1 -1
- package/src/form-flow/structure.ts +4 -24
- package/src/types/page-flip.d.ts +37 -0
|
@@ -0,0 +1,1381 @@
|
|
|
1
|
+
import { t as W } from "./chunk-Fx_iipZ-.js";
|
|
2
|
+
var E = /* @__PURE__ */ W(((m, I) => {
|
|
3
|
+
(function(u, c) {
|
|
4
|
+
typeof m == "object" && typeof I < "u" ? c(m) : typeof define == "function" && define.amd ? define(["exports"], c) : c((u = u || self).St = {});
|
|
5
|
+
})(m, (function(u) {
|
|
6
|
+
"use strict";
|
|
7
|
+
class c {
|
|
8
|
+
constructor(t, e) {
|
|
9
|
+
this.state = {
|
|
10
|
+
angle: 0,
|
|
11
|
+
area: [],
|
|
12
|
+
position: {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0
|
|
15
|
+
},
|
|
16
|
+
hardAngle: 0,
|
|
17
|
+
hardDrawingAngle: 0
|
|
18
|
+
}, this.createdDensity = e, this.nowDrawingDensity = this.createdDensity, this.render = t;
|
|
19
|
+
}
|
|
20
|
+
setDensity(t) {
|
|
21
|
+
this.createdDensity = t, this.nowDrawingDensity = t;
|
|
22
|
+
}
|
|
23
|
+
setDrawingDensity(t) {
|
|
24
|
+
this.nowDrawingDensity = t;
|
|
25
|
+
}
|
|
26
|
+
setPosition(t) {
|
|
27
|
+
this.state.position = t;
|
|
28
|
+
}
|
|
29
|
+
setAngle(t) {
|
|
30
|
+
this.state.angle = t;
|
|
31
|
+
}
|
|
32
|
+
setArea(t) {
|
|
33
|
+
this.state.area = t;
|
|
34
|
+
}
|
|
35
|
+
setHardDrawingAngle(t) {
|
|
36
|
+
this.state.hardDrawingAngle = t;
|
|
37
|
+
}
|
|
38
|
+
setHardAngle(t) {
|
|
39
|
+
this.state.hardAngle = t, this.state.hardDrawingAngle = t;
|
|
40
|
+
}
|
|
41
|
+
setOrientation(t) {
|
|
42
|
+
this.orientation = t;
|
|
43
|
+
}
|
|
44
|
+
getDrawingDensity() {
|
|
45
|
+
return this.nowDrawingDensity;
|
|
46
|
+
}
|
|
47
|
+
getDensity() {
|
|
48
|
+
return this.createdDensity;
|
|
49
|
+
}
|
|
50
|
+
getHardAngle() {
|
|
51
|
+
return this.state.hardAngle;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class T extends c {
|
|
55
|
+
constructor(t, e, i) {
|
|
56
|
+
super(t, i), this.image = null, this.isLoad = !1, this.loadingAngle = 0, this.image = new Image(), this.image.src = e;
|
|
57
|
+
}
|
|
58
|
+
draw(t) {
|
|
59
|
+
const e = this.render.getContext(), i = this.render.convertToGlobal(this.state.position), s = this.render.getRect().pageWidth, n = this.render.getRect().height;
|
|
60
|
+
e.save(), e.translate(i.x, i.y), e.beginPath();
|
|
61
|
+
for (let h of this.state.area) h !== null && (h = this.render.convertToGlobal(h), e.lineTo(h.x - i.x, h.y - i.y));
|
|
62
|
+
e.rotate(this.state.angle), e.clip(), this.isLoad ? e.drawImage(this.image, 0, 0, s, n) : this.drawLoader(e, {
|
|
63
|
+
x: 0,
|
|
64
|
+
y: 0
|
|
65
|
+
}, s, n), e.restore();
|
|
66
|
+
}
|
|
67
|
+
simpleDraw(t) {
|
|
68
|
+
const e = this.render.getRect(), i = this.render.getContext(), s = e.pageWidth, n = e.height, h = t === 1 ? e.left + e.pageWidth : e.left, o = e.top;
|
|
69
|
+
this.isLoad ? i.drawImage(this.image, h, o, s, n) : this.drawLoader(i, {
|
|
70
|
+
x: h,
|
|
71
|
+
y: o
|
|
72
|
+
}, s, n);
|
|
73
|
+
}
|
|
74
|
+
drawLoader(t, e, i, s) {
|
|
75
|
+
t.beginPath(), t.strokeStyle = "rgb(200, 200, 200)", t.fillStyle = "rgb(255, 255, 255)", t.lineWidth = 1, t.rect(e.x + 1, e.y + 1, i - 1, s - 1), t.stroke(), t.fill();
|
|
76
|
+
const n = {
|
|
77
|
+
x: e.x + i / 2,
|
|
78
|
+
y: e.y + s / 2
|
|
79
|
+
};
|
|
80
|
+
t.beginPath(), t.lineWidth = 10, t.arc(n.x, n.y, 20, this.loadingAngle, 3 * Math.PI / 2 + this.loadingAngle), t.stroke(), t.closePath(), this.loadingAngle += 0.07, this.loadingAngle >= 2 * Math.PI && (this.loadingAngle = 0);
|
|
81
|
+
}
|
|
82
|
+
load() {
|
|
83
|
+
this.isLoad || (this.image.onload = () => {
|
|
84
|
+
this.isLoad = !0;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
newTemporaryCopy() {
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
getTemporaryCopy() {
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
hideTemporaryCopy() {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class f {
|
|
97
|
+
constructor(t, e) {
|
|
98
|
+
this.pages = [], this.currentPageIndex = 0, this.currentSpreadIndex = 0, this.landscapeSpread = [], this.portraitSpread = [], this.render = e, this.app = t, this.currentPageIndex = 0, this.isShowCover = this.app.getSettings().showCover;
|
|
99
|
+
}
|
|
100
|
+
destroy() {
|
|
101
|
+
this.pages = [];
|
|
102
|
+
}
|
|
103
|
+
createSpread() {
|
|
104
|
+
this.landscapeSpread = [], this.portraitSpread = [];
|
|
105
|
+
for (let e = 0; e < this.pages.length; e++) this.portraitSpread.push([e]);
|
|
106
|
+
let t = 0;
|
|
107
|
+
this.isShowCover && (this.pages[0].setDensity("hard"), this.landscapeSpread.push([t]), t++);
|
|
108
|
+
for (let e = t; e < this.pages.length; e += 2) e < this.pages.length - 1 ? this.landscapeSpread.push([e, e + 1]) : (this.landscapeSpread.push([e]), this.pages[e].setDensity("hard"));
|
|
109
|
+
}
|
|
110
|
+
getSpread() {
|
|
111
|
+
return this.render.getOrientation() === "landscape" ? this.landscapeSpread : this.portraitSpread;
|
|
112
|
+
}
|
|
113
|
+
getSpreadIndexByPage(t) {
|
|
114
|
+
const e = this.getSpread();
|
|
115
|
+
for (let i = 0; i < e.length; i++) if (t === e[i][0] || t === e[i][1]) return i;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
getPageCount() {
|
|
119
|
+
return this.pages.length;
|
|
120
|
+
}
|
|
121
|
+
getPages() {
|
|
122
|
+
return this.pages;
|
|
123
|
+
}
|
|
124
|
+
getPage(t) {
|
|
125
|
+
if (t >= 0 && t < this.pages.length) return this.pages[t];
|
|
126
|
+
throw new Error("Invalid page number");
|
|
127
|
+
}
|
|
128
|
+
nextBy(t) {
|
|
129
|
+
const e = this.pages.indexOf(t);
|
|
130
|
+
return e < this.pages.length - 1 ? this.pages[e + 1] : null;
|
|
131
|
+
}
|
|
132
|
+
prevBy(t) {
|
|
133
|
+
const e = this.pages.indexOf(t);
|
|
134
|
+
return e > 0 ? this.pages[e - 1] : null;
|
|
135
|
+
}
|
|
136
|
+
getFlippingPage(t) {
|
|
137
|
+
const e = this.currentSpreadIndex;
|
|
138
|
+
if (this.render.getOrientation() === "portrait") return t === 0 ? this.pages[e].newTemporaryCopy() : this.pages[e - 1];
|
|
139
|
+
{
|
|
140
|
+
const i = t === 0 ? this.getSpread()[e + 1] : this.getSpread()[e - 1];
|
|
141
|
+
return i.length === 1 || t === 0 ? this.pages[i[0]] : this.pages[i[1]];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
getBottomPage(t) {
|
|
145
|
+
const e = this.currentSpreadIndex;
|
|
146
|
+
if (this.render.getOrientation() === "portrait") return t === 0 ? this.pages[e + 1] : this.pages[e - 1];
|
|
147
|
+
{
|
|
148
|
+
const i = t === 0 ? this.getSpread()[e + 1] : this.getSpread()[e - 1];
|
|
149
|
+
return i.length === 1 ? this.pages[i[0]] : t === 0 ? this.pages[i[1]] : this.pages[i[0]];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
showNext() {
|
|
153
|
+
this.currentSpreadIndex < this.getSpread().length && (this.currentSpreadIndex++, this.showSpread());
|
|
154
|
+
}
|
|
155
|
+
showPrev() {
|
|
156
|
+
this.currentSpreadIndex > 0 && (this.currentSpreadIndex--, this.showSpread());
|
|
157
|
+
}
|
|
158
|
+
getCurrentPageIndex() {
|
|
159
|
+
return this.currentPageIndex;
|
|
160
|
+
}
|
|
161
|
+
show(t = null) {
|
|
162
|
+
if (t === null && (t = this.currentPageIndex), t < 0 || t >= this.pages.length) return;
|
|
163
|
+
const e = this.getSpreadIndexByPage(t);
|
|
164
|
+
e !== null && (this.currentSpreadIndex = e, this.showSpread());
|
|
165
|
+
}
|
|
166
|
+
getCurrentSpreadIndex() {
|
|
167
|
+
return this.currentSpreadIndex;
|
|
168
|
+
}
|
|
169
|
+
setCurrentSpreadIndex(t) {
|
|
170
|
+
if (!(t >= 0 && t < this.getSpread().length)) throw new Error("Invalid page");
|
|
171
|
+
this.currentSpreadIndex = t;
|
|
172
|
+
}
|
|
173
|
+
showSpread() {
|
|
174
|
+
const t = this.getSpread()[this.currentSpreadIndex];
|
|
175
|
+
t.length === 2 ? (this.render.setLeftPage(this.pages[t[0]]), this.render.setRightPage(this.pages[t[1]])) : this.render.getOrientation() === "landscape" && t[0] === this.pages.length - 1 ? (this.render.setLeftPage(this.pages[t[0]]), this.render.setRightPage(null)) : (this.render.setLeftPage(null), this.render.setRightPage(this.pages[t[0]])), this.currentPageIndex = t[0], this.app.updatePageIndex(this.currentPageIndex);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
class y extends f {
|
|
179
|
+
constructor(t, e, i) {
|
|
180
|
+
super(t, e), this.imagesHref = i;
|
|
181
|
+
}
|
|
182
|
+
load() {
|
|
183
|
+
for (const t of this.imagesHref) {
|
|
184
|
+
const e = new T(this.render, t, "soft");
|
|
185
|
+
e.load(), this.pages.push(e);
|
|
186
|
+
}
|
|
187
|
+
this.createSpread();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
class l {
|
|
191
|
+
static GetDistanceBetweenTwoPoint(t, e) {
|
|
192
|
+
return t === null || e === null ? 1 / 0 : Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2));
|
|
193
|
+
}
|
|
194
|
+
static GetSegmentLength(t) {
|
|
195
|
+
return l.GetDistanceBetweenTwoPoint(t[0], t[1]);
|
|
196
|
+
}
|
|
197
|
+
static GetAngleBetweenTwoLine(t, e) {
|
|
198
|
+
const i = t[0].y - t[1].y, s = e[0].y - e[1].y, n = t[1].x - t[0].x, h = e[1].x - e[0].x;
|
|
199
|
+
return Math.acos((i * s + n * h) / (Math.sqrt(i * i + n * n) * Math.sqrt(s * s + h * h)));
|
|
200
|
+
}
|
|
201
|
+
static PointInRect(t, e) {
|
|
202
|
+
return e === null ? null : e.x >= t.left && e.x <= t.width + t.left && e.y >= t.top && e.y <= t.top + t.height ? e : null;
|
|
203
|
+
}
|
|
204
|
+
static GetRotatedPoint(t, e, i) {
|
|
205
|
+
return {
|
|
206
|
+
x: t.x * Math.cos(i) + t.y * Math.sin(i) + e.x,
|
|
207
|
+
y: t.y * Math.cos(i) - t.x * Math.sin(i) + e.y
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
static LimitPointToCircle(t, e, i) {
|
|
211
|
+
if (l.GetDistanceBetweenTwoPoint(t, i) <= e) return i;
|
|
212
|
+
const s = t.x, n = t.y, h = i.x, o = i.y;
|
|
213
|
+
let a = Math.sqrt(Math.pow(e, 2) * Math.pow(s - h, 2) / (Math.pow(s - h, 2) + Math.pow(n - o, 2))) + s;
|
|
214
|
+
i.x < 0 && (a *= -1);
|
|
215
|
+
let g = (a - s) * (n - o) / (s - h) + n;
|
|
216
|
+
return s - h + n === 0 && (g = e), {
|
|
217
|
+
x: a,
|
|
218
|
+
y: g
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
static GetIntersectBetweenTwoSegment(t, e, i) {
|
|
222
|
+
return l.PointInRect(t, l.GetIntersectBeetwenTwoLine(e, i));
|
|
223
|
+
}
|
|
224
|
+
static GetIntersectBeetwenTwoLine(t, e) {
|
|
225
|
+
const i = t[0].y - t[1].y, s = e[0].y - e[1].y, n = t[1].x - t[0].x, h = e[1].x - e[0].x, o = t[0].x * t[1].y - t[1].x * t[0].y, a = e[0].x * e[1].y - e[1].x * e[0].y, g = i * a - s * o, d = n * a - h * o, p = -(o * h - a * n) / (i * h - s * n), w = -(i * a - s * o) / (i * h - s * n);
|
|
226
|
+
if (isFinite(p) && isFinite(w)) return {
|
|
227
|
+
x: p,
|
|
228
|
+
y: w
|
|
229
|
+
};
|
|
230
|
+
if (Math.abs(g - d) < 0.1) throw new Error("Segment included");
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
static GetCordsFromTwoPoint(t, e) {
|
|
234
|
+
const i = Math.abs(t.x - e.x), s = Math.abs(t.y - e.y), n = Math.max(i, s), h = [t];
|
|
235
|
+
function o(a, g, d, p, w) {
|
|
236
|
+
return g > a ? a + w * (d / p) : g < a ? a - w * (d / p) : a;
|
|
237
|
+
}
|
|
238
|
+
for (let a = 1; a <= n; a += 1) h.push({
|
|
239
|
+
x: o(t.x, e.x, i, n, a),
|
|
240
|
+
y: o(t.y, e.y, s, n, a)
|
|
241
|
+
});
|
|
242
|
+
return h;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
class x extends c {
|
|
246
|
+
constructor(t, e, i) {
|
|
247
|
+
super(t, i), this.copiedElement = null, this.temporaryCopy = null, this.isLoad = !1, this.element = e, this.element.classList.add("stf__item"), this.element.classList.add("--" + i);
|
|
248
|
+
}
|
|
249
|
+
newTemporaryCopy() {
|
|
250
|
+
return this.nowDrawingDensity === "hard" ? this : (this.temporaryCopy === null && (this.copiedElement = this.element.cloneNode(!0), this.element.parentElement.appendChild(this.copiedElement), this.temporaryCopy = new x(this.render, this.copiedElement, this.nowDrawingDensity)), this.getTemporaryCopy());
|
|
251
|
+
}
|
|
252
|
+
getTemporaryCopy() {
|
|
253
|
+
return this.temporaryCopy;
|
|
254
|
+
}
|
|
255
|
+
hideTemporaryCopy() {
|
|
256
|
+
this.temporaryCopy !== null && (this.copiedElement.remove(), this.copiedElement = null, this.temporaryCopy = null);
|
|
257
|
+
}
|
|
258
|
+
draw(t) {
|
|
259
|
+
const e = t || this.nowDrawingDensity, i = this.render.convertToGlobal(this.state.position), s = this.render.getRect().pageWidth, n = this.render.getRect().height;
|
|
260
|
+
this.element.classList.remove("--simple");
|
|
261
|
+
const h = `
|
|
262
|
+
display: block;
|
|
263
|
+
z-index: ${this.element.style.zIndex};
|
|
264
|
+
left: 0;
|
|
265
|
+
top: 0;
|
|
266
|
+
width: ${s}px;
|
|
267
|
+
height: ${n}px;
|
|
268
|
+
`;
|
|
269
|
+
e === "hard" ? this.drawHard(h) : this.drawSoft(i, h);
|
|
270
|
+
}
|
|
271
|
+
drawHard(t = "") {
|
|
272
|
+
const e = this.render.getRect().left + this.render.getRect().width / 2, i = this.state.hardDrawingAngle, s = t + `
|
|
273
|
+
backface-visibility: hidden;
|
|
274
|
+
-webkit-backface-visibility: hidden;
|
|
275
|
+
clip-path: none;
|
|
276
|
+
-webkit-clip-path: none;
|
|
277
|
+
` + (this.orientation === 0 ? `transform-origin: ${this.render.getRect().pageWidth}px 0;
|
|
278
|
+
transform: translate3d(0, 0, 0) rotateY(${i}deg);` : `transform-origin: 0 0;
|
|
279
|
+
transform: translate3d(${e}px, 0, 0) rotateY(${i}deg);`);
|
|
280
|
+
this.element.style.cssText = s;
|
|
281
|
+
}
|
|
282
|
+
drawSoft(t, e = "") {
|
|
283
|
+
let i = "polygon( ";
|
|
284
|
+
for (const n of this.state.area) if (n !== null) {
|
|
285
|
+
let h = this.render.getDirection() === 1 ? {
|
|
286
|
+
x: -n.x + this.state.position.x,
|
|
287
|
+
y: n.y - this.state.position.y
|
|
288
|
+
} : {
|
|
289
|
+
x: n.x - this.state.position.x,
|
|
290
|
+
y: n.y - this.state.position.y
|
|
291
|
+
};
|
|
292
|
+
h = l.GetRotatedPoint(h, {
|
|
293
|
+
x: 0,
|
|
294
|
+
y: 0
|
|
295
|
+
}, this.state.angle), i += h.x + "px " + h.y + "px, ";
|
|
296
|
+
}
|
|
297
|
+
i = i.slice(0, -2), i += ")";
|
|
298
|
+
const s = e + `transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};` + (this.render.isSafari() && this.state.angle === 0 ? `transform: translate(${t.x}px, ${t.y}px);` : `transform: translate3d(${t.x}px, ${t.y}px, 0) rotate(${this.state.angle}rad);`);
|
|
299
|
+
this.element.style.cssText = s;
|
|
300
|
+
}
|
|
301
|
+
simpleDraw(t) {
|
|
302
|
+
const e = this.render.getRect(), i = e.pageWidth, s = e.height, n = t === 1 ? e.left + e.pageWidth : e.left, h = e.top;
|
|
303
|
+
this.element.classList.add("--simple"), this.element.style.cssText = `
|
|
304
|
+
position: absolute;
|
|
305
|
+
display: block;
|
|
306
|
+
height: ${s}px;
|
|
307
|
+
left: ${n}px;
|
|
308
|
+
top: ${h}px;
|
|
309
|
+
width: ${i}px;
|
|
310
|
+
z-index: ${this.render.getSettings().startZIndex + 1};`;
|
|
311
|
+
}
|
|
312
|
+
getElement() {
|
|
313
|
+
return this.element;
|
|
314
|
+
}
|
|
315
|
+
load() {
|
|
316
|
+
this.isLoad = !0;
|
|
317
|
+
}
|
|
318
|
+
setOrientation(t) {
|
|
319
|
+
super.setOrientation(t), this.element.classList.remove("--left", "--right"), this.element.classList.add(t === 1 ? "--right" : "--left");
|
|
320
|
+
}
|
|
321
|
+
setDrawingDensity(t) {
|
|
322
|
+
this.element.classList.remove("--soft", "--hard"), this.element.classList.add("--" + t), super.setDrawingDensity(t);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
class P extends f {
|
|
326
|
+
constructor(t, e, i, s) {
|
|
327
|
+
super(t, e), this.element = i, this.pagesElement = s;
|
|
328
|
+
}
|
|
329
|
+
load() {
|
|
330
|
+
for (const t of this.pagesElement) {
|
|
331
|
+
const e = new x(this.render, t, t.dataset.density === "hard" ? "hard" : "soft");
|
|
332
|
+
e.load(), this.pages.push(e);
|
|
333
|
+
}
|
|
334
|
+
this.createSpread();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
class C {
|
|
338
|
+
constructor(t, e, i, s) {
|
|
339
|
+
this.direction = t, this.corner = e, this.topIntersectPoint = null, this.sideIntersectPoint = null, this.bottomIntersectPoint = null, this.pageWidth = parseInt(i, 10), this.pageHeight = parseInt(s, 10);
|
|
340
|
+
}
|
|
341
|
+
calc(t) {
|
|
342
|
+
try {
|
|
343
|
+
return this.position = this.calcAngleAndPosition(t), this.calculateIntersectPoint(this.position), !0;
|
|
344
|
+
} catch {
|
|
345
|
+
return !1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
getFlippingClipArea() {
|
|
349
|
+
const t = [];
|
|
350
|
+
let e = !1;
|
|
351
|
+
return t.push(this.rect.topLeft), t.push(this.topIntersectPoint), this.sideIntersectPoint === null ? e = !0 : (t.push(this.sideIntersectPoint), this.bottomIntersectPoint === null && (e = !1)), t.push(this.bottomIntersectPoint), (e || this.corner === "bottom") && t.push(this.rect.bottomLeft), t;
|
|
352
|
+
}
|
|
353
|
+
getBottomClipArea() {
|
|
354
|
+
const t = [];
|
|
355
|
+
return t.push(this.topIntersectPoint), this.corner === "top" ? t.push({
|
|
356
|
+
x: this.pageWidth,
|
|
357
|
+
y: 0
|
|
358
|
+
}) : (this.topIntersectPoint !== null && t.push({
|
|
359
|
+
x: this.pageWidth,
|
|
360
|
+
y: 0
|
|
361
|
+
}), t.push({
|
|
362
|
+
x: this.pageWidth,
|
|
363
|
+
y: this.pageHeight
|
|
364
|
+
})), this.sideIntersectPoint !== null ? l.GetDistanceBetweenTwoPoint(this.sideIntersectPoint, this.topIntersectPoint) >= 10 && t.push(this.sideIntersectPoint) : this.corner === "top" && t.push({
|
|
365
|
+
x: this.pageWidth,
|
|
366
|
+
y: this.pageHeight
|
|
367
|
+
}), t.push(this.bottomIntersectPoint), t.push(this.topIntersectPoint), t;
|
|
368
|
+
}
|
|
369
|
+
getAngle() {
|
|
370
|
+
return this.direction === 0 ? -this.angle : this.angle;
|
|
371
|
+
}
|
|
372
|
+
getRect() {
|
|
373
|
+
return this.rect;
|
|
374
|
+
}
|
|
375
|
+
getPosition() {
|
|
376
|
+
return this.position;
|
|
377
|
+
}
|
|
378
|
+
getActiveCorner() {
|
|
379
|
+
return this.direction === 0 ? this.rect.topLeft : this.rect.topRight;
|
|
380
|
+
}
|
|
381
|
+
getDirection() {
|
|
382
|
+
return this.direction;
|
|
383
|
+
}
|
|
384
|
+
getFlippingProgress() {
|
|
385
|
+
return Math.abs((this.position.x - this.pageWidth) / (2 * this.pageWidth) * 100);
|
|
386
|
+
}
|
|
387
|
+
getCorner() {
|
|
388
|
+
return this.corner;
|
|
389
|
+
}
|
|
390
|
+
getBottomPagePosition() {
|
|
391
|
+
return this.direction === 1 ? {
|
|
392
|
+
x: this.pageWidth,
|
|
393
|
+
y: 0
|
|
394
|
+
} : {
|
|
395
|
+
x: 0,
|
|
396
|
+
y: 0
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
getShadowStartPoint() {
|
|
400
|
+
return this.corner === "top" ? this.topIntersectPoint : this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.topIntersectPoint;
|
|
401
|
+
}
|
|
402
|
+
getShadowAngle() {
|
|
403
|
+
const t = l.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(), [{
|
|
404
|
+
x: 0,
|
|
405
|
+
y: 0
|
|
406
|
+
}, {
|
|
407
|
+
x: this.pageWidth,
|
|
408
|
+
y: 0
|
|
409
|
+
}]);
|
|
410
|
+
return this.direction === 0 ? t : Math.PI - t;
|
|
411
|
+
}
|
|
412
|
+
calcAngleAndPosition(t) {
|
|
413
|
+
let e = t;
|
|
414
|
+
if (this.updateAngleAndGeometry(e), e = this.corner === "top" ? this.checkPositionAtCenterLine(e, {
|
|
415
|
+
x: 0,
|
|
416
|
+
y: 0
|
|
417
|
+
}, {
|
|
418
|
+
x: 0,
|
|
419
|
+
y: this.pageHeight
|
|
420
|
+
}) : this.checkPositionAtCenterLine(e, {
|
|
421
|
+
x: 0,
|
|
422
|
+
y: this.pageHeight
|
|
423
|
+
}, {
|
|
424
|
+
x: 0,
|
|
425
|
+
y: 0
|
|
426
|
+
}), Math.abs(e.x - this.pageWidth) < 1 && Math.abs(e.y) < 1) throw new Error("Point is too small");
|
|
427
|
+
return e;
|
|
428
|
+
}
|
|
429
|
+
updateAngleAndGeometry(t) {
|
|
430
|
+
this.angle = this.calculateAngle(t), this.rect = this.getPageRect(t);
|
|
431
|
+
}
|
|
432
|
+
calculateAngle(t) {
|
|
433
|
+
const e = this.pageWidth - t.x + 1, i = this.corner === "bottom" ? this.pageHeight - t.y : t.y;
|
|
434
|
+
let s = 2 * Math.acos(e / Math.sqrt(i * i + e * e));
|
|
435
|
+
i < 0 && (s = -s);
|
|
436
|
+
const n = Math.PI - s;
|
|
437
|
+
if (!isFinite(s) || n >= 0 && n < 3e-3) throw new Error("The G point is too small");
|
|
438
|
+
return this.corner === "bottom" && (s = -s), s;
|
|
439
|
+
}
|
|
440
|
+
getPageRect(t) {
|
|
441
|
+
return this.corner === "top" ? this.getRectFromBasePoint([
|
|
442
|
+
{
|
|
443
|
+
x: 0,
|
|
444
|
+
y: 0
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
x: this.pageWidth,
|
|
448
|
+
y: 0
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
x: 0,
|
|
452
|
+
y: this.pageHeight
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
x: this.pageWidth,
|
|
456
|
+
y: this.pageHeight
|
|
457
|
+
}
|
|
458
|
+
], t) : this.getRectFromBasePoint([
|
|
459
|
+
{
|
|
460
|
+
x: 0,
|
|
461
|
+
y: -this.pageHeight
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
x: this.pageWidth,
|
|
465
|
+
y: -this.pageHeight
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
x: 0,
|
|
469
|
+
y: 0
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
x: this.pageWidth,
|
|
473
|
+
y: 0
|
|
474
|
+
}
|
|
475
|
+
], t);
|
|
476
|
+
}
|
|
477
|
+
getRectFromBasePoint(t, e) {
|
|
478
|
+
return {
|
|
479
|
+
topLeft: this.getRotatedPoint(t[0], e),
|
|
480
|
+
topRight: this.getRotatedPoint(t[1], e),
|
|
481
|
+
bottomLeft: this.getRotatedPoint(t[2], e),
|
|
482
|
+
bottomRight: this.getRotatedPoint(t[3], e)
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
getRotatedPoint(t, e) {
|
|
486
|
+
return {
|
|
487
|
+
x: t.x * Math.cos(this.angle) + t.y * Math.sin(this.angle) + e.x,
|
|
488
|
+
y: t.y * Math.cos(this.angle) - t.x * Math.sin(this.angle) + e.y
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
calculateIntersectPoint(t) {
|
|
492
|
+
const e = {
|
|
493
|
+
left: -1,
|
|
494
|
+
top: -1,
|
|
495
|
+
width: this.pageWidth + 2,
|
|
496
|
+
height: this.pageHeight + 2
|
|
497
|
+
};
|
|
498
|
+
this.corner === "top" ? (this.topIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [t, this.rect.topRight], [{
|
|
499
|
+
x: 0,
|
|
500
|
+
y: 0
|
|
501
|
+
}, {
|
|
502
|
+
x: this.pageWidth,
|
|
503
|
+
y: 0
|
|
504
|
+
}]), this.sideIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [t, this.rect.bottomLeft], [{
|
|
505
|
+
x: this.pageWidth,
|
|
506
|
+
y: 0
|
|
507
|
+
}, {
|
|
508
|
+
x: this.pageWidth,
|
|
509
|
+
y: this.pageHeight
|
|
510
|
+
}]), this.bottomIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [this.rect.bottomLeft, this.rect.bottomRight], [{
|
|
511
|
+
x: 0,
|
|
512
|
+
y: this.pageHeight
|
|
513
|
+
}, {
|
|
514
|
+
x: this.pageWidth,
|
|
515
|
+
y: this.pageHeight
|
|
516
|
+
}])) : (this.topIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [this.rect.topLeft, this.rect.topRight], [{
|
|
517
|
+
x: 0,
|
|
518
|
+
y: 0
|
|
519
|
+
}, {
|
|
520
|
+
x: this.pageWidth,
|
|
521
|
+
y: 0
|
|
522
|
+
}]), this.sideIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [t, this.rect.topLeft], [{
|
|
523
|
+
x: this.pageWidth,
|
|
524
|
+
y: 0
|
|
525
|
+
}, {
|
|
526
|
+
x: this.pageWidth,
|
|
527
|
+
y: this.pageHeight
|
|
528
|
+
}]), this.bottomIntersectPoint = l.GetIntersectBetweenTwoSegment(e, [this.rect.bottomLeft, this.rect.bottomRight], [{
|
|
529
|
+
x: 0,
|
|
530
|
+
y: this.pageHeight
|
|
531
|
+
}, {
|
|
532
|
+
x: this.pageWidth,
|
|
533
|
+
y: this.pageHeight
|
|
534
|
+
}]));
|
|
535
|
+
}
|
|
536
|
+
checkPositionAtCenterLine(t, e, i) {
|
|
537
|
+
let s = t;
|
|
538
|
+
const n = l.LimitPointToCircle(e, this.pageWidth, s);
|
|
539
|
+
s !== n && (s = n, this.updateAngleAndGeometry(s));
|
|
540
|
+
const h = Math.sqrt(Math.pow(this.pageWidth, 2) + Math.pow(this.pageHeight, 2));
|
|
541
|
+
let o = this.rect.bottomRight, a = this.rect.topLeft;
|
|
542
|
+
if (this.corner === "bottom" && (o = this.rect.topRight, a = this.rect.bottomLeft), o.x <= 0) {
|
|
543
|
+
const g = l.LimitPointToCircle(i, h, a);
|
|
544
|
+
g !== s && (s = g, this.updateAngleAndGeometry(s));
|
|
545
|
+
}
|
|
546
|
+
return s;
|
|
547
|
+
}
|
|
548
|
+
getSegmentToShadowLine() {
|
|
549
|
+
const t = this.getShadowStartPoint();
|
|
550
|
+
return [t, t !== this.sideIntersectPoint && this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.bottomIntersectPoint];
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
class S {
|
|
554
|
+
constructor(t, e) {
|
|
555
|
+
this.flippingPage = null, this.bottomPage = null, this.calc = null, this.state = "read", this.render = t, this.app = e;
|
|
556
|
+
}
|
|
557
|
+
fold(t) {
|
|
558
|
+
this.setState("user_fold"), this.calc === null && this.start(t), this.do(this.render.convertToPage(t));
|
|
559
|
+
}
|
|
560
|
+
flip(t) {
|
|
561
|
+
if (this.app.getSettings().disableFlipByClick && !this.isPointOnCorners(t) || (this.calc !== null && this.render.finishAnimation(), !this.start(t))) return;
|
|
562
|
+
const e = this.getBoundsRect();
|
|
563
|
+
this.setState("flipping");
|
|
564
|
+
const i = e.height / 10, s = this.calc.getCorner() === "bottom" ? e.height - i : i, n = this.calc.getCorner() === "bottom" ? e.height : 0;
|
|
565
|
+
this.calc.calc({
|
|
566
|
+
x: e.pageWidth - i,
|
|
567
|
+
y: s
|
|
568
|
+
}), this.animateFlippingTo({
|
|
569
|
+
x: e.pageWidth - i,
|
|
570
|
+
y: s
|
|
571
|
+
}, {
|
|
572
|
+
x: -e.pageWidth,
|
|
573
|
+
y: n
|
|
574
|
+
}, !0);
|
|
575
|
+
}
|
|
576
|
+
start(t) {
|
|
577
|
+
this.reset();
|
|
578
|
+
const e = this.render.convertToBook(t), i = this.getBoundsRect(), s = this.getDirectionByPoint(e), n = e.y >= i.height / 2 ? "bottom" : "top";
|
|
579
|
+
if (!this.checkDirection(s)) return !1;
|
|
580
|
+
try {
|
|
581
|
+
if (this.flippingPage = this.app.getPageCollection().getFlippingPage(s), this.bottomPage = this.app.getPageCollection().getBottomPage(s), this.render.getOrientation() === "landscape") if (s === 1) {
|
|
582
|
+
const h = this.app.getPageCollection().nextBy(this.flippingPage);
|
|
583
|
+
h !== null && this.flippingPage.getDensity() !== h.getDensity() && (this.flippingPage.setDrawingDensity("hard"), h.setDrawingDensity("hard"));
|
|
584
|
+
} else {
|
|
585
|
+
const h = this.app.getPageCollection().prevBy(this.flippingPage);
|
|
586
|
+
h !== null && this.flippingPage.getDensity() !== h.getDensity() && (this.flippingPage.setDrawingDensity("hard"), h.setDrawingDensity("hard"));
|
|
587
|
+
}
|
|
588
|
+
return this.render.setDirection(s), this.calc = new C(s, n, i.pageWidth.toString(10), i.height.toString(10)), !0;
|
|
589
|
+
} catch {
|
|
590
|
+
return !1;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
do(t) {
|
|
594
|
+
if (this.calc !== null && this.calc.calc(t)) {
|
|
595
|
+
const e = this.calc.getFlippingProgress();
|
|
596
|
+
this.bottomPage.setArea(this.calc.getBottomClipArea()), this.bottomPage.setPosition(this.calc.getBottomPagePosition()), this.bottomPage.setAngle(0), this.bottomPage.setHardAngle(0), this.flippingPage.setArea(this.calc.getFlippingClipArea()), this.flippingPage.setPosition(this.calc.getActiveCorner()), this.flippingPage.setAngle(this.calc.getAngle()), this.calc.getDirection() === 0 ? this.flippingPage.setHardAngle(90 * (200 - 2 * e) / 100) : this.flippingPage.setHardAngle(-90 * (200 - 2 * e) / 100), this.render.setPageRect(this.calc.getRect()), this.render.setBottomPage(this.bottomPage), this.render.setFlippingPage(this.flippingPage), this.render.setShadowData(this.calc.getShadowStartPoint(), this.calc.getShadowAngle(), e, this.calc.getDirection());
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
flipToPage(t, e) {
|
|
600
|
+
const i = this.app.getPageCollection().getCurrentSpreadIndex(), s = this.app.getPageCollection().getSpreadIndexByPage(t);
|
|
601
|
+
try {
|
|
602
|
+
s > i && (this.app.getPageCollection().setCurrentSpreadIndex(s - 1), this.flipNext(e)), s < i && (this.app.getPageCollection().setCurrentSpreadIndex(s + 1), this.flipPrev(e));
|
|
603
|
+
} catch {
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
flipNext(t) {
|
|
607
|
+
this.flip({
|
|
608
|
+
x: this.render.getRect().left + 2 * this.render.getRect().pageWidth - 10,
|
|
609
|
+
y: t === "top" ? 1 : this.render.getRect().height - 2
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
flipPrev(t) {
|
|
613
|
+
this.flip({
|
|
614
|
+
x: 10,
|
|
615
|
+
y: t === "top" ? 1 : this.render.getRect().height - 2
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
stopMove() {
|
|
619
|
+
if (this.calc === null) return;
|
|
620
|
+
const t = this.calc.getPosition(), e = this.getBoundsRect(), i = this.calc.getCorner() === "bottom" ? e.height : 0;
|
|
621
|
+
t.x <= 0 ? this.animateFlippingTo(t, {
|
|
622
|
+
x: -e.pageWidth,
|
|
623
|
+
y: i
|
|
624
|
+
}, !0) : this.animateFlippingTo(t, {
|
|
625
|
+
x: e.pageWidth,
|
|
626
|
+
y: i
|
|
627
|
+
}, !1);
|
|
628
|
+
}
|
|
629
|
+
showCorner(t) {
|
|
630
|
+
if (!this.checkState("read", "fold_corner")) return;
|
|
631
|
+
const e = this.getBoundsRect(), i = e.pageWidth;
|
|
632
|
+
if (this.isPointOnCorners(t)) if (this.calc === null) {
|
|
633
|
+
if (!this.start(t)) return;
|
|
634
|
+
this.setState("fold_corner"), this.calc.calc({
|
|
635
|
+
x: i - 1,
|
|
636
|
+
y: 1
|
|
637
|
+
});
|
|
638
|
+
const s = 50, n = this.calc.getCorner() === "bottom" ? e.height - 1 : 1, h = this.calc.getCorner() === "bottom" ? e.height - s : s;
|
|
639
|
+
this.animateFlippingTo({
|
|
640
|
+
x: i - 1,
|
|
641
|
+
y: n
|
|
642
|
+
}, {
|
|
643
|
+
x: i - s,
|
|
644
|
+
y: h
|
|
645
|
+
}, !1, !1);
|
|
646
|
+
} else this.do(this.render.convertToPage(t));
|
|
647
|
+
else this.setState("read"), this.render.finishAnimation(), this.stopMove();
|
|
648
|
+
}
|
|
649
|
+
animateFlippingTo(t, e, i, s = !0) {
|
|
650
|
+
const n = l.GetCordsFromTwoPoint(t, e), h = [];
|
|
651
|
+
for (const a of n) h.push(() => this.do(a));
|
|
652
|
+
const o = this.getAnimationDuration(n.length);
|
|
653
|
+
this.render.startAnimation(h, o, () => {
|
|
654
|
+
this.calc && (i && (this.calc.getDirection() === 1 ? this.app.turnToPrevPage() : this.app.turnToNextPage()), s && (this.render.setBottomPage(null), this.render.setFlippingPage(null), this.render.clearShadow(), this.setState("read"), this.reset()));
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
getCalculation() {
|
|
658
|
+
return this.calc;
|
|
659
|
+
}
|
|
660
|
+
getState() {
|
|
661
|
+
return this.state;
|
|
662
|
+
}
|
|
663
|
+
setState(t) {
|
|
664
|
+
this.state !== t && (this.app.updateState(t), this.state = t);
|
|
665
|
+
}
|
|
666
|
+
getDirectionByPoint(t) {
|
|
667
|
+
const e = this.getBoundsRect();
|
|
668
|
+
if (this.render.getOrientation() === "portrait") {
|
|
669
|
+
if (t.x - e.pageWidth <= e.width / 5) return 1;
|
|
670
|
+
} else if (t.x < e.width / 2) return 1;
|
|
671
|
+
return 0;
|
|
672
|
+
}
|
|
673
|
+
getAnimationDuration(t) {
|
|
674
|
+
const e = this.app.getSettings().flippingTime;
|
|
675
|
+
return t >= 1e3 ? e : t / 1e3 * e;
|
|
676
|
+
}
|
|
677
|
+
checkDirection(t) {
|
|
678
|
+
return t === 0 ? this.app.getCurrentPageIndex() < this.app.getPageCount() - 1 : this.app.getCurrentPageIndex() >= 1;
|
|
679
|
+
}
|
|
680
|
+
reset() {
|
|
681
|
+
this.calc = null, this.flippingPage = null, this.bottomPage = null;
|
|
682
|
+
}
|
|
683
|
+
getBoundsRect() {
|
|
684
|
+
return this.render.getRect();
|
|
685
|
+
}
|
|
686
|
+
checkState(...t) {
|
|
687
|
+
for (const e of t) if (this.state === e) return !0;
|
|
688
|
+
return !1;
|
|
689
|
+
}
|
|
690
|
+
isPointOnCorners(t) {
|
|
691
|
+
const e = this.getBoundsRect(), i = e.pageWidth, s = Math.sqrt(Math.pow(i, 2) + Math.pow(e.height, 2)) / 5, n = this.render.convertToBook(t);
|
|
692
|
+
return n.x > 0 && n.y > 0 && n.x < e.width && n.y < e.height && (n.x < s || n.x > e.width - s) && (n.y < s || n.y > e.height - s);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
class b {
|
|
696
|
+
constructor(t, e) {
|
|
697
|
+
this.leftPage = null, this.rightPage = null, this.flippingPage = null, this.bottomPage = null, this.direction = null, this.orientation = null, this.shadow = null, this.animation = null, this.pageRect = null, this.boundsRect = null, this.timer = 0, this.safari = !1, this.setting = e, this.app = t, this.safari = (/* @__PURE__ */ new RegExp("Version\\/[\\d\\.]+.*Safari/")).exec(window.navigator.userAgent) !== null;
|
|
698
|
+
}
|
|
699
|
+
render(t) {
|
|
700
|
+
if (this.animation !== null) {
|
|
701
|
+
const e = Math.round((t - this.animation.startedAt) / this.animation.durationFrame);
|
|
702
|
+
e < this.animation.frames.length ? this.animation.frames[e]() : (this.animation.onAnimateEnd(), this.animation = null);
|
|
703
|
+
}
|
|
704
|
+
this.timer = t, this.drawFrame();
|
|
705
|
+
}
|
|
706
|
+
start() {
|
|
707
|
+
this.update();
|
|
708
|
+
const t = (e) => {
|
|
709
|
+
this.render(e), requestAnimationFrame(t);
|
|
710
|
+
};
|
|
711
|
+
requestAnimationFrame(t);
|
|
712
|
+
}
|
|
713
|
+
startAnimation(t, e, i) {
|
|
714
|
+
this.finishAnimation(), this.animation = {
|
|
715
|
+
frames: t,
|
|
716
|
+
duration: e,
|
|
717
|
+
durationFrame: e / t.length,
|
|
718
|
+
onAnimateEnd: i,
|
|
719
|
+
startedAt: this.timer
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
finishAnimation() {
|
|
723
|
+
this.animation !== null && (this.animation.frames[this.animation.frames.length - 1](), this.animation.onAnimateEnd !== null && this.animation.onAnimateEnd()), this.animation = null;
|
|
724
|
+
}
|
|
725
|
+
update() {
|
|
726
|
+
this.boundsRect = null;
|
|
727
|
+
const t = this.calculateBoundsRect();
|
|
728
|
+
this.orientation !== t && (this.orientation = t, this.app.updateOrientation(t));
|
|
729
|
+
}
|
|
730
|
+
calculateBoundsRect() {
|
|
731
|
+
let t = "landscape";
|
|
732
|
+
const e = this.getBlockWidth(), i = e / 2, s = this.getBlockHeight() / 2, n = this.setting.width / this.setting.height;
|
|
733
|
+
let h = this.setting.width, o = this.setting.height, a = i - h;
|
|
734
|
+
return this.setting.size === "stretch" ? (e < 2 * this.setting.minWidth && this.app.getSettings().usePortrait && (t = "portrait"), h = t === "portrait" ? this.getBlockWidth() : this.getBlockWidth() / 2, h > this.setting.maxWidth && (h = this.setting.maxWidth), o = h / n, o > this.getBlockHeight() && (o = this.getBlockHeight(), h = o * n), a = t === "portrait" ? i - h / 2 - h : i - h) : e < 2 * h && this.app.getSettings().usePortrait && (t = "portrait", a = i - h / 2 - h), this.boundsRect = {
|
|
735
|
+
left: a,
|
|
736
|
+
top: s - o / 2,
|
|
737
|
+
width: 2 * h,
|
|
738
|
+
height: o,
|
|
739
|
+
pageWidth: h
|
|
740
|
+
}, t;
|
|
741
|
+
}
|
|
742
|
+
setShadowData(t, e, i, s) {
|
|
743
|
+
if (!this.app.getSettings().drawShadow) return;
|
|
744
|
+
const n = 100 * this.getSettings().maxShadowOpacity;
|
|
745
|
+
this.shadow = {
|
|
746
|
+
pos: t,
|
|
747
|
+
angle: e,
|
|
748
|
+
width: 3 * this.getRect().pageWidth / 4 * i / 100,
|
|
749
|
+
opacity: (100 - i) * n / 100 / 100,
|
|
750
|
+
direction: s,
|
|
751
|
+
progress: 2 * i
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
clearShadow() {
|
|
755
|
+
this.shadow = null;
|
|
756
|
+
}
|
|
757
|
+
getBlockWidth() {
|
|
758
|
+
return this.app.getUI().getDistElement().offsetWidth;
|
|
759
|
+
}
|
|
760
|
+
getBlockHeight() {
|
|
761
|
+
return this.app.getUI().getDistElement().offsetHeight;
|
|
762
|
+
}
|
|
763
|
+
getDirection() {
|
|
764
|
+
return this.direction;
|
|
765
|
+
}
|
|
766
|
+
getRect() {
|
|
767
|
+
return this.boundsRect === null && this.calculateBoundsRect(), this.boundsRect;
|
|
768
|
+
}
|
|
769
|
+
getSettings() {
|
|
770
|
+
return this.app.getSettings();
|
|
771
|
+
}
|
|
772
|
+
getOrientation() {
|
|
773
|
+
return this.orientation;
|
|
774
|
+
}
|
|
775
|
+
setPageRect(t) {
|
|
776
|
+
this.pageRect = t;
|
|
777
|
+
}
|
|
778
|
+
setDirection(t) {
|
|
779
|
+
this.direction = t;
|
|
780
|
+
}
|
|
781
|
+
setRightPage(t) {
|
|
782
|
+
t !== null && t.setOrientation(1), this.rightPage = t;
|
|
783
|
+
}
|
|
784
|
+
setLeftPage(t) {
|
|
785
|
+
t !== null && t.setOrientation(0), this.leftPage = t;
|
|
786
|
+
}
|
|
787
|
+
setBottomPage(t) {
|
|
788
|
+
t !== null && t.setOrientation(this.direction === 1 ? 0 : 1), this.bottomPage = t;
|
|
789
|
+
}
|
|
790
|
+
setFlippingPage(t) {
|
|
791
|
+
t !== null && t.setOrientation(this.direction === 0 && this.orientation !== "portrait" ? 0 : 1), this.flippingPage = t;
|
|
792
|
+
}
|
|
793
|
+
convertToBook(t) {
|
|
794
|
+
const e = this.getRect();
|
|
795
|
+
return {
|
|
796
|
+
x: t.x - e.left,
|
|
797
|
+
y: t.y - e.top
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
isSafari() {
|
|
801
|
+
return this.safari;
|
|
802
|
+
}
|
|
803
|
+
convertToPage(t, e) {
|
|
804
|
+
e || (e = this.direction);
|
|
805
|
+
const i = this.getRect();
|
|
806
|
+
return {
|
|
807
|
+
x: e === 0 ? t.x - i.left - i.width / 2 : i.width / 2 - t.x + i.left,
|
|
808
|
+
y: t.y - i.top
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
convertToGlobal(t, e) {
|
|
812
|
+
if (e || (e = this.direction), t == null) return null;
|
|
813
|
+
const i = this.getRect();
|
|
814
|
+
return {
|
|
815
|
+
x: e === 0 ? t.x + i.left + i.width / 2 : i.width / 2 - t.x + i.left,
|
|
816
|
+
y: t.y + i.top
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
convertRectToGlobal(t, e) {
|
|
820
|
+
return e || (e = this.direction), {
|
|
821
|
+
topLeft: this.convertToGlobal(t.topLeft, e),
|
|
822
|
+
topRight: this.convertToGlobal(t.topRight, e),
|
|
823
|
+
bottomLeft: this.convertToGlobal(t.bottomLeft, e),
|
|
824
|
+
bottomRight: this.convertToGlobal(t.bottomRight, e)
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
class D extends b {
|
|
829
|
+
constructor(t, e, i) {
|
|
830
|
+
super(t, e), this.canvas = i, this.ctx = i.getContext("2d");
|
|
831
|
+
}
|
|
832
|
+
getContext() {
|
|
833
|
+
return this.ctx;
|
|
834
|
+
}
|
|
835
|
+
reload() {
|
|
836
|
+
}
|
|
837
|
+
drawFrame() {
|
|
838
|
+
this.clear(), this.orientation !== "portrait" && this.leftPage != null && this.leftPage.simpleDraw(0), this.rightPage != null && this.rightPage.simpleDraw(1), this.bottomPage != null && this.bottomPage.draw(), this.drawBookShadow(), this.flippingPage != null && this.flippingPage.draw(), this.shadow != null && (this.drawOuterShadow(), this.drawInnerShadow());
|
|
839
|
+
const t = this.getRect();
|
|
840
|
+
this.orientation === "portrait" && (this.ctx.beginPath(), this.ctx.rect(t.left + t.pageWidth, t.top, t.width, t.height), this.ctx.clip());
|
|
841
|
+
}
|
|
842
|
+
drawBookShadow() {
|
|
843
|
+
const t = this.getRect();
|
|
844
|
+
this.ctx.save(), this.ctx.beginPath();
|
|
845
|
+
const e = t.width / 20;
|
|
846
|
+
this.ctx.rect(t.left, t.top, t.width, t.height);
|
|
847
|
+
const i = {
|
|
848
|
+
x: t.left + t.width / 2 - e / 2,
|
|
849
|
+
y: 0
|
|
850
|
+
};
|
|
851
|
+
this.ctx.translate(i.x, i.y);
|
|
852
|
+
const s = this.ctx.createLinearGradient(0, 0, e, 0);
|
|
853
|
+
s.addColorStop(0, "rgba(0, 0, 0, 0)"), s.addColorStop(0.4, "rgba(0, 0, 0, 0.2)"), s.addColorStop(0.49, "rgba(0, 0, 0, 0.1)"), s.addColorStop(0.5, "rgba(0, 0, 0, 0.5)"), s.addColorStop(0.51, "rgba(0, 0, 0, 0.4)"), s.addColorStop(1, "rgba(0, 0, 0, 0)"), this.ctx.clip(), this.ctx.fillStyle = s, this.ctx.fillRect(0, 0, e, 2 * t.height), this.ctx.restore();
|
|
854
|
+
}
|
|
855
|
+
drawOuterShadow() {
|
|
856
|
+
const t = this.getRect();
|
|
857
|
+
this.ctx.save(), this.ctx.beginPath(), this.ctx.rect(t.left, t.top, t.width, t.height);
|
|
858
|
+
const e = this.convertToGlobal({
|
|
859
|
+
x: this.shadow.pos.x,
|
|
860
|
+
y: this.shadow.pos.y
|
|
861
|
+
});
|
|
862
|
+
this.ctx.translate(e.x, e.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
|
|
863
|
+
const i = this.ctx.createLinearGradient(0, 0, this.shadow.width, 0);
|
|
864
|
+
this.shadow.direction === 0 ? (this.ctx.translate(0, -100), i.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), i.addColorStop(1, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(-this.shadow.width, -100), i.addColorStop(0, "rgba(0, 0, 0, 0)"), i.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")")), this.ctx.clip(), this.ctx.fillStyle = i, this.ctx.fillRect(0, 0, this.shadow.width, 2 * t.height), this.ctx.restore();
|
|
865
|
+
}
|
|
866
|
+
drawInnerShadow() {
|
|
867
|
+
const t = this.getRect();
|
|
868
|
+
this.ctx.save(), this.ctx.beginPath();
|
|
869
|
+
const e = this.convertToGlobal({
|
|
870
|
+
x: this.shadow.pos.x,
|
|
871
|
+
y: this.shadow.pos.y
|
|
872
|
+
}), i = this.convertRectToGlobal(this.pageRect);
|
|
873
|
+
this.ctx.moveTo(i.topLeft.x, i.topLeft.y), this.ctx.lineTo(i.topRight.x, i.topRight.y), this.ctx.lineTo(i.bottomRight.x, i.bottomRight.y), this.ctx.lineTo(i.bottomLeft.x, i.bottomLeft.y), this.ctx.translate(e.x, e.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
|
|
874
|
+
const s = 3 * this.shadow.width / 4, n = this.ctx.createLinearGradient(0, 0, s, 0);
|
|
875
|
+
this.shadow.direction === 0 ? (this.ctx.translate(-s, -100), n.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), n.addColorStop(0.9, "rgba(0, 0, 0, 0.05)"), n.addColorStop(0.7, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), n.addColorStop(0, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(0, -100), n.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), n.addColorStop(0.1, "rgba(0, 0, 0, 0.05)"), n.addColorStop(0.3, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), n.addColorStop(1, "rgba(0, 0, 0, 0)")), this.ctx.clip(), this.ctx.fillStyle = n, this.ctx.fillRect(0, 0, s, 2 * t.height), this.ctx.restore();
|
|
876
|
+
}
|
|
877
|
+
clear() {
|
|
878
|
+
this.ctx.fillStyle = "white", this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
class v {
|
|
882
|
+
constructor(t, e, i) {
|
|
883
|
+
this.touchPoint = null, this.swipeTimeout = 250, this.onResize = () => {
|
|
884
|
+
this.update();
|
|
885
|
+
}, this.onMouseDown = (n) => {
|
|
886
|
+
if (this.checkTarget(n.target)) {
|
|
887
|
+
const h = this.getMousePos(n.clientX, n.clientY);
|
|
888
|
+
this.app.startUserTouch(h), n.preventDefault();
|
|
889
|
+
}
|
|
890
|
+
}, this.onTouchStart = (n) => {
|
|
891
|
+
if (this.checkTarget(n.target) && n.changedTouches.length > 0) {
|
|
892
|
+
const h = n.changedTouches[0], o = this.getMousePos(h.clientX, h.clientY);
|
|
893
|
+
this.touchPoint = {
|
|
894
|
+
point: o,
|
|
895
|
+
time: Date.now()
|
|
896
|
+
}, setTimeout(() => {
|
|
897
|
+
this.touchPoint !== null && this.app.startUserTouch(o);
|
|
898
|
+
}, this.swipeTimeout), this.app.getSettings().mobileScrollSupport || n.preventDefault();
|
|
899
|
+
}
|
|
900
|
+
}, this.onMouseUp = (n) => {
|
|
901
|
+
const h = this.getMousePos(n.clientX, n.clientY);
|
|
902
|
+
this.app.userStop(h);
|
|
903
|
+
}, this.onMouseMove = (n) => {
|
|
904
|
+
const h = this.getMousePos(n.clientX, n.clientY);
|
|
905
|
+
this.app.userMove(h, !1);
|
|
906
|
+
}, this.onTouchMove = (n) => {
|
|
907
|
+
if (n.changedTouches.length > 0) {
|
|
908
|
+
const h = n.changedTouches[0], o = this.getMousePos(h.clientX, h.clientY);
|
|
909
|
+
this.app.getSettings().mobileScrollSupport ? (this.touchPoint !== null && (Math.abs(this.touchPoint.point.x - o.x) > 10 || this.app.getState() !== "read") && n.cancelable && this.app.userMove(o, !0), this.app.getState() !== "read" && n.preventDefault()) : this.app.userMove(o, !0);
|
|
910
|
+
}
|
|
911
|
+
}, this.onTouchEnd = (n) => {
|
|
912
|
+
if (n.changedTouches.length > 0) {
|
|
913
|
+
const h = n.changedTouches[0], o = this.getMousePos(h.clientX, h.clientY);
|
|
914
|
+
let a = !1;
|
|
915
|
+
if (this.touchPoint !== null) {
|
|
916
|
+
const g = o.x - this.touchPoint.point.x, d = Math.abs(o.y - this.touchPoint.point.y);
|
|
917
|
+
Math.abs(g) > this.swipeDistance && d < 2 * this.swipeDistance && Date.now() - this.touchPoint.time < this.swipeTimeout && (g > 0 ? this.app.flipPrev(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom") : this.app.flipNext(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom"), a = !0), this.touchPoint = null;
|
|
918
|
+
}
|
|
919
|
+
this.app.userStop(o, a);
|
|
920
|
+
}
|
|
921
|
+
}, this.parentElement = t, t.classList.add("stf__parent"), t.insertAdjacentHTML("afterbegin", '<div class="stf__wrapper"></div>'), this.wrapper = t.querySelector(".stf__wrapper"), this.app = e;
|
|
922
|
+
const s = this.app.getSettings().usePortrait ? 1 : 2;
|
|
923
|
+
t.style.minWidth = i.minWidth * s + "px", t.style.minHeight = i.minHeight + "px", i.size === "fixed" && (t.style.minWidth = i.width * s + "px", t.style.minHeight = i.height + "px"), i.autoSize && (t.style.width = "100%", t.style.maxWidth = 2 * i.maxWidth + "px"), t.style.display = "block", window.addEventListener("resize", this.onResize, !1), this.swipeDistance = i.swipeDistance;
|
|
924
|
+
}
|
|
925
|
+
destroy() {
|
|
926
|
+
this.app.getSettings().useMouseEvents && this.removeHandlers(), this.distElement.remove(), this.wrapper.remove();
|
|
927
|
+
}
|
|
928
|
+
getDistElement() {
|
|
929
|
+
return this.distElement;
|
|
930
|
+
}
|
|
931
|
+
getWrapper() {
|
|
932
|
+
return this.wrapper;
|
|
933
|
+
}
|
|
934
|
+
setOrientationStyle(t) {
|
|
935
|
+
this.wrapper.classList.remove("--portrait", "--landscape"), t === "portrait" ? (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / this.app.getSettings().width * 100 + "%"), this.wrapper.classList.add("--portrait")) : (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / (2 * this.app.getSettings().width) * 100 + "%"), this.wrapper.classList.add("--landscape")), this.update();
|
|
936
|
+
}
|
|
937
|
+
removeHandlers() {
|
|
938
|
+
window.removeEventListener("resize", this.onResize), this.distElement.removeEventListener("mousedown", this.onMouseDown), this.distElement.removeEventListener("touchstart", this.onTouchStart), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("touchend", this.onTouchEnd);
|
|
939
|
+
}
|
|
940
|
+
setHandlers() {
|
|
941
|
+
window.addEventListener("resize", this.onResize, !1), this.app.getSettings().useMouseEvents && (this.distElement.addEventListener("mousedown", this.onMouseDown), this.distElement.addEventListener("touchstart", this.onTouchStart), window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("touchmove", this.onTouchMove, { passive: !this.app.getSettings().mobileScrollSupport }), window.addEventListener("mouseup", this.onMouseUp), window.addEventListener("touchend", this.onTouchEnd));
|
|
942
|
+
}
|
|
943
|
+
getMousePos(t, e) {
|
|
944
|
+
const i = this.distElement.getBoundingClientRect();
|
|
945
|
+
return {
|
|
946
|
+
x: t - i.left,
|
|
947
|
+
y: e - i.top
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
checkTarget(t) {
|
|
951
|
+
return !this.app.getSettings().clickEventForward || !["a", "button"].includes(t.tagName.toLowerCase());
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
class R extends v {
|
|
955
|
+
constructor(t, e, i, s) {
|
|
956
|
+
super(t, e, i), this.wrapper.insertAdjacentHTML("afterbegin", '<div class="stf__block"></div>'), this.distElement = t.querySelector(".stf__block"), this.items = s;
|
|
957
|
+
for (const n of s) this.distElement.appendChild(n);
|
|
958
|
+
this.setHandlers();
|
|
959
|
+
}
|
|
960
|
+
clear() {
|
|
961
|
+
for (const t of this.items) this.parentElement.appendChild(t);
|
|
962
|
+
}
|
|
963
|
+
updateItems(t) {
|
|
964
|
+
this.removeHandlers(), this.distElement.innerHTML = "";
|
|
965
|
+
for (const e of t) this.distElement.appendChild(e);
|
|
966
|
+
this.items = t, this.setHandlers();
|
|
967
|
+
}
|
|
968
|
+
update() {
|
|
969
|
+
this.app.getRender().update();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
class M extends v {
|
|
973
|
+
constructor(t, e, i) {
|
|
974
|
+
super(t, e, i), this.wrapper.innerHTML = '<canvas class="stf__canvas"></canvas>', this.canvas = t.querySelectorAll("canvas")[0], this.distElement = this.canvas, this.resizeCanvas(), this.setHandlers();
|
|
975
|
+
}
|
|
976
|
+
resizeCanvas() {
|
|
977
|
+
const t = getComputedStyle(this.canvas), e = parseInt(t.getPropertyValue("width"), 10), i = parseInt(t.getPropertyValue("height"), 10);
|
|
978
|
+
this.canvas.width = e, this.canvas.height = i;
|
|
979
|
+
}
|
|
980
|
+
getCanvas() {
|
|
981
|
+
return this.canvas;
|
|
982
|
+
}
|
|
983
|
+
update() {
|
|
984
|
+
this.resizeCanvas(), this.app.getRender().update();
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
class L extends b {
|
|
988
|
+
constructor(t, e, i) {
|
|
989
|
+
super(t, e), this.outerShadow = null, this.innerShadow = null, this.hardShadow = null, this.hardInnerShadow = null, this.element = i, this.createShadows();
|
|
990
|
+
}
|
|
991
|
+
createShadows() {
|
|
992
|
+
this.element.insertAdjacentHTML("beforeend", `<div class="stf__outerShadow"></div>
|
|
993
|
+
<div class="stf__innerShadow"></div>
|
|
994
|
+
<div class="stf__hardShadow"></div>
|
|
995
|
+
<div class="stf__hardInnerShadow"></div>`), this.outerShadow = this.element.querySelector(".stf__outerShadow"), this.innerShadow = this.element.querySelector(".stf__innerShadow"), this.hardShadow = this.element.querySelector(".stf__hardShadow"), this.hardInnerShadow = this.element.querySelector(".stf__hardInnerShadow");
|
|
996
|
+
}
|
|
997
|
+
clearShadow() {
|
|
998
|
+
super.clearShadow(), this.outerShadow.style.cssText = "display: none", this.innerShadow.style.cssText = "display: none", this.hardShadow.style.cssText = "display: none", this.hardInnerShadow.style.cssText = "display: none";
|
|
999
|
+
}
|
|
1000
|
+
reload() {
|
|
1001
|
+
this.element.querySelector(".stf__outerShadow") || this.createShadows();
|
|
1002
|
+
}
|
|
1003
|
+
drawHardInnerShadow() {
|
|
1004
|
+
const t = this.getRect(), e = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
|
|
1005
|
+
let i = (100 - e) * (2.5 * t.pageWidth) / 100 + 20;
|
|
1006
|
+
i > t.pageWidth && (i = t.pageWidth);
|
|
1007
|
+
let s = `
|
|
1008
|
+
display: block;
|
|
1009
|
+
z-index: ${(this.getSettings().startZIndex + 5).toString(10)};
|
|
1010
|
+
width: ${i}px;
|
|
1011
|
+
height: ${t.height}px;
|
|
1012
|
+
background: linear-gradient(to right,
|
|
1013
|
+
rgba(0, 0, 0, ${this.shadow.opacity * e / 100}) 5%,
|
|
1014
|
+
rgba(0, 0, 0, 0) 100%);
|
|
1015
|
+
left: ${t.left + t.width / 2}px;
|
|
1016
|
+
transform-origin: 0 0;
|
|
1017
|
+
`;
|
|
1018
|
+
s += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0);" : "transform: translate3d(0, 0, 0) rotateY(180deg);", this.hardInnerShadow.style.cssText = s;
|
|
1019
|
+
}
|
|
1020
|
+
drawHardOuterShadow() {
|
|
1021
|
+
const t = this.getRect();
|
|
1022
|
+
let e = (100 - (this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress)) * (2.5 * t.pageWidth) / 100 + 20;
|
|
1023
|
+
e > t.pageWidth && (e = t.pageWidth);
|
|
1024
|
+
let i = `
|
|
1025
|
+
display: block;
|
|
1026
|
+
z-index: ${(this.getSettings().startZIndex + 4).toString(10)};
|
|
1027
|
+
width: ${e}px;
|
|
1028
|
+
height: ${t.height}px;
|
|
1029
|
+
background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
|
|
1030
|
+
left: ${t.left + t.width / 2}px;
|
|
1031
|
+
transform-origin: 0 0;
|
|
1032
|
+
`;
|
|
1033
|
+
i += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0) rotateY(180deg);" : "transform: translate3d(0, 0, 0);", this.hardShadow.style.cssText = i;
|
|
1034
|
+
}
|
|
1035
|
+
drawInnerShadow() {
|
|
1036
|
+
const t = this.getRect(), e = 3 * this.shadow.width / 4, i = this.getDirection() === 0 ? e : 0, s = this.getDirection() === 0 ? "to left" : "to right", n = this.convertToGlobal(this.shadow.pos), h = this.shadow.angle + 3 * Math.PI / 2, o = [
|
|
1037
|
+
this.pageRect.topLeft,
|
|
1038
|
+
this.pageRect.topRight,
|
|
1039
|
+
this.pageRect.bottomRight,
|
|
1040
|
+
this.pageRect.bottomLeft
|
|
1041
|
+
];
|
|
1042
|
+
let a = "polygon( ";
|
|
1043
|
+
for (const d of o) {
|
|
1044
|
+
let p = this.getDirection() === 1 ? {
|
|
1045
|
+
x: -d.x + this.shadow.pos.x,
|
|
1046
|
+
y: d.y - this.shadow.pos.y
|
|
1047
|
+
} : {
|
|
1048
|
+
x: d.x - this.shadow.pos.x,
|
|
1049
|
+
y: d.y - this.shadow.pos.y
|
|
1050
|
+
};
|
|
1051
|
+
p = l.GetRotatedPoint(p, {
|
|
1052
|
+
x: i,
|
|
1053
|
+
y: 100
|
|
1054
|
+
}, h), a += p.x + "px " + p.y + "px, ";
|
|
1055
|
+
}
|
|
1056
|
+
a = a.slice(0, -2), a += ")";
|
|
1057
|
+
const g = `
|
|
1058
|
+
display: block;
|
|
1059
|
+
z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
|
|
1060
|
+
width: ${e}px;
|
|
1061
|
+
height: ${2 * t.height}px;
|
|
1062
|
+
background: linear-gradient(${s},
|
|
1063
|
+
rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
|
|
1064
|
+
rgba(0, 0, 0, 0.05) 15%,
|
|
1065
|
+
rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
|
|
1066
|
+
rgba(0, 0, 0, 0) 100%);
|
|
1067
|
+
transform-origin: ${i}px 100px;
|
|
1068
|
+
transform: translate3d(${n.x - i}px, ${n.y - 100}px, 0) rotate(${h}rad);
|
|
1069
|
+
clip-path: ${a};
|
|
1070
|
+
-webkit-clip-path: ${a};
|
|
1071
|
+
`;
|
|
1072
|
+
this.innerShadow.style.cssText = g;
|
|
1073
|
+
}
|
|
1074
|
+
drawOuterShadow() {
|
|
1075
|
+
const t = this.getRect(), e = this.convertToGlobal({
|
|
1076
|
+
x: this.shadow.pos.x,
|
|
1077
|
+
y: this.shadow.pos.y
|
|
1078
|
+
}), i = this.shadow.angle + 3 * Math.PI / 2, s = this.getDirection() === 1 ? this.shadow.width : 0, n = this.getDirection() === 0 ? "to right" : "to left", h = [
|
|
1079
|
+
{
|
|
1080
|
+
x: 0,
|
|
1081
|
+
y: 0
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
x: t.pageWidth,
|
|
1085
|
+
y: 0
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
x: t.pageWidth,
|
|
1089
|
+
y: t.height
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
x: 0,
|
|
1093
|
+
y: t.height
|
|
1094
|
+
}
|
|
1095
|
+
];
|
|
1096
|
+
let o = "polygon( ";
|
|
1097
|
+
for (const g of h) if (g !== null) {
|
|
1098
|
+
let d = this.getDirection() === 1 ? {
|
|
1099
|
+
x: -g.x + this.shadow.pos.x,
|
|
1100
|
+
y: g.y - this.shadow.pos.y
|
|
1101
|
+
} : {
|
|
1102
|
+
x: g.x - this.shadow.pos.x,
|
|
1103
|
+
y: g.y - this.shadow.pos.y
|
|
1104
|
+
};
|
|
1105
|
+
d = l.GetRotatedPoint(d, {
|
|
1106
|
+
x: s,
|
|
1107
|
+
y: 100
|
|
1108
|
+
}, i), o += d.x + "px " + d.y + "px, ";
|
|
1109
|
+
}
|
|
1110
|
+
o = o.slice(0, -2), o += ")";
|
|
1111
|
+
const a = `
|
|
1112
|
+
display: block;
|
|
1113
|
+
z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
|
|
1114
|
+
width: ${this.shadow.width}px;
|
|
1115
|
+
height: ${2 * t.height}px;
|
|
1116
|
+
background: linear-gradient(${n}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
|
|
1117
|
+
transform-origin: ${s}px 100px;
|
|
1118
|
+
transform: translate3d(${e.x - s}px, ${e.y - 100}px, 0) rotate(${i}rad);
|
|
1119
|
+
clip-path: ${o};
|
|
1120
|
+
-webkit-clip-path: ${o};
|
|
1121
|
+
`;
|
|
1122
|
+
this.outerShadow.style.cssText = a;
|
|
1123
|
+
}
|
|
1124
|
+
drawLeftPage() {
|
|
1125
|
+
this.orientation !== "portrait" && this.leftPage !== null && (this.direction === 1 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.leftPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.leftPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.leftPage.draw(this.flippingPage.getDrawingDensity())) : this.leftPage.simpleDraw(0));
|
|
1126
|
+
}
|
|
1127
|
+
drawRightPage() {
|
|
1128
|
+
this.rightPage !== null && (this.direction === 0 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.rightPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.rightPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.rightPage.draw(this.flippingPage.getDrawingDensity())) : this.rightPage.simpleDraw(1));
|
|
1129
|
+
}
|
|
1130
|
+
drawBottomPage() {
|
|
1131
|
+
if (this.bottomPage === null) return;
|
|
1132
|
+
const t = this.flippingPage != null ? this.flippingPage.getDrawingDensity() : null;
|
|
1133
|
+
this.orientation === "portrait" && this.direction === 1 || (this.bottomPage.getElement().style.zIndex = (this.getSettings().startZIndex + 3).toString(10), this.bottomPage.draw(t));
|
|
1134
|
+
}
|
|
1135
|
+
drawFrame() {
|
|
1136
|
+
this.clear(), this.drawLeftPage(), this.drawRightPage(), this.drawBottomPage(), this.flippingPage != null && (this.flippingPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.flippingPage.draw()), this.shadow != null && this.flippingPage !== null && (this.flippingPage.getDrawingDensity() === "soft" ? (this.drawOuterShadow(), this.drawInnerShadow()) : (this.drawHardOuterShadow(), this.drawHardInnerShadow()));
|
|
1137
|
+
}
|
|
1138
|
+
clear() {
|
|
1139
|
+
for (const t of this.app.getPageCollection().getPages()) t !== this.leftPage && t !== this.rightPage && t !== this.flippingPage && t !== this.bottomPage && (t.getElement().style.cssText = "display: none"), t.getTemporaryCopy() !== this.flippingPage && t.hideTemporaryCopy();
|
|
1140
|
+
}
|
|
1141
|
+
update() {
|
|
1142
|
+
super.update(), this.rightPage !== null && this.rightPage.setOrientation(1), this.leftPage !== null && this.leftPage.setOrientation(0);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
class A {
|
|
1146
|
+
constructor() {
|
|
1147
|
+
this._default = {
|
|
1148
|
+
startPage: 0,
|
|
1149
|
+
size: "fixed",
|
|
1150
|
+
width: 0,
|
|
1151
|
+
height: 0,
|
|
1152
|
+
minWidth: 0,
|
|
1153
|
+
maxWidth: 0,
|
|
1154
|
+
minHeight: 0,
|
|
1155
|
+
maxHeight: 0,
|
|
1156
|
+
drawShadow: !0,
|
|
1157
|
+
flippingTime: 1e3,
|
|
1158
|
+
usePortrait: !0,
|
|
1159
|
+
startZIndex: 0,
|
|
1160
|
+
autoSize: !0,
|
|
1161
|
+
maxShadowOpacity: 1,
|
|
1162
|
+
showCover: !1,
|
|
1163
|
+
mobileScrollSupport: !0,
|
|
1164
|
+
swipeDistance: 30,
|
|
1165
|
+
clickEventForward: !0,
|
|
1166
|
+
useMouseEvents: !0,
|
|
1167
|
+
showPageCorners: !0,
|
|
1168
|
+
disableFlipByClick: !1
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
getSettings(t) {
|
|
1172
|
+
const e = this._default;
|
|
1173
|
+
if (Object.assign(e, t), e.size !== "stretch" && e.size !== "fixed") throw new Error('Invalid size type. Available only "fixed" and "stretch" value');
|
|
1174
|
+
if (e.width <= 0 || e.height <= 0) throw new Error("Invalid width or height");
|
|
1175
|
+
if (e.flippingTime <= 0) throw new Error("Invalid flipping time");
|
|
1176
|
+
return e.size === "stretch" ? (e.minWidth <= 0 && (e.minWidth = 100), e.maxWidth < e.minWidth && (e.maxWidth = 2e3), e.minHeight <= 0 && (e.minHeight = 100), e.maxHeight < e.minHeight && (e.maxHeight = 2e3)) : (e.minWidth = e.width, e.maxWidth = e.width, e.minHeight = e.height, e.maxHeight = e.height), e;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
(function(r, t) {
|
|
1180
|
+
t === void 0 && (t = {});
|
|
1181
|
+
var e = t.insertAt;
|
|
1182
|
+
if (r && typeof document < "u") {
|
|
1183
|
+
var i = document.head || document.getElementsByTagName("head")[0], s = document.createElement("style");
|
|
1184
|
+
s.type = "text/css", e === "top" && i.firstChild ? i.insertBefore(s, i.firstChild) : i.appendChild(s), s.styleSheet ? s.styleSheet.cssText = r : s.appendChild(document.createTextNode(r));
|
|
1185
|
+
}
|
|
1186
|
+
})(`.stf__parent {
|
|
1187
|
+
position: relative;
|
|
1188
|
+
display: block;
|
|
1189
|
+
box-sizing: border-box;
|
|
1190
|
+
transform: translateZ(0);
|
|
1191
|
+
|
|
1192
|
+
-ms-touch-action: pan-y;
|
|
1193
|
+
touch-action: pan-y;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
.sft__wrapper {
|
|
1197
|
+
position: relative;
|
|
1198
|
+
width: 100%;
|
|
1199
|
+
box-sizing: border-box;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
.stf__parent canvas {
|
|
1203
|
+
position: absolute;
|
|
1204
|
+
width: 100%;
|
|
1205
|
+
height: 100%;
|
|
1206
|
+
left: 0;
|
|
1207
|
+
top: 0;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
.stf__block {
|
|
1211
|
+
position: absolute;
|
|
1212
|
+
width: 100%;
|
|
1213
|
+
height: 100%;
|
|
1214
|
+
box-sizing: border-box;
|
|
1215
|
+
perspective: 2000px;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
.stf__item {
|
|
1219
|
+
display: none;
|
|
1220
|
+
position: absolute;
|
|
1221
|
+
transform-style: preserve-3d;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
.stf__outerShadow {
|
|
1225
|
+
position: absolute;
|
|
1226
|
+
left: 0;
|
|
1227
|
+
top: 0;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
.stf__innerShadow {
|
|
1231
|
+
position: absolute;
|
|
1232
|
+
left: 0;
|
|
1233
|
+
top: 0;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
.stf__hardShadow {
|
|
1237
|
+
position: absolute;
|
|
1238
|
+
left: 0;
|
|
1239
|
+
top: 0;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
.stf__hardInnerShadow {
|
|
1243
|
+
position: absolute;
|
|
1244
|
+
left: 0;
|
|
1245
|
+
top: 0;
|
|
1246
|
+
}`), u.PageFlip = class extends class {
|
|
1247
|
+
constructor() {
|
|
1248
|
+
this.events = /* @__PURE__ */ new Map();
|
|
1249
|
+
}
|
|
1250
|
+
on(r, t) {
|
|
1251
|
+
return this.events.has(r) ? this.events.get(r).push(t) : this.events.set(r, [t]), this;
|
|
1252
|
+
}
|
|
1253
|
+
off(r) {
|
|
1254
|
+
this.events.delete(r);
|
|
1255
|
+
}
|
|
1256
|
+
trigger(r, t, e = null) {
|
|
1257
|
+
if (this.events.has(r)) for (const i of this.events.get(r)) i({
|
|
1258
|
+
data: e,
|
|
1259
|
+
object: t
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
} {
|
|
1263
|
+
constructor(r, t) {
|
|
1264
|
+
super(), this.isUserTouch = !1, this.isUserMove = !1, this.setting = null, this.pages = null, this.setting = new A().getSettings(t), this.block = r;
|
|
1265
|
+
}
|
|
1266
|
+
destroy() {
|
|
1267
|
+
this.ui.destroy(), this.block.remove();
|
|
1268
|
+
}
|
|
1269
|
+
update() {
|
|
1270
|
+
this.render.update(), this.pages.show();
|
|
1271
|
+
}
|
|
1272
|
+
loadFromImages(r) {
|
|
1273
|
+
this.ui = new M(this.block, this, this.setting);
|
|
1274
|
+
const t = this.ui.getCanvas();
|
|
1275
|
+
this.render = new D(this, this.setting, t), this.flipController = new S(this.render, this), this.pages = new y(this, this.render, r), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
|
|
1276
|
+
this.ui.update(), this.trigger("init", this, {
|
|
1277
|
+
page: this.setting.startPage,
|
|
1278
|
+
mode: this.render.getOrientation()
|
|
1279
|
+
});
|
|
1280
|
+
}, 1);
|
|
1281
|
+
}
|
|
1282
|
+
loadFromHTML(r) {
|
|
1283
|
+
this.ui = new R(this.block, this, this.setting, r), this.render = new L(this, this.setting, this.ui.getDistElement()), this.flipController = new S(this.render, this), this.pages = new P(this, this.render, this.ui.getDistElement(), r), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
|
|
1284
|
+
this.ui.update(), this.trigger("init", this, {
|
|
1285
|
+
page: this.setting.startPage,
|
|
1286
|
+
mode: this.render.getOrientation()
|
|
1287
|
+
});
|
|
1288
|
+
}, 1);
|
|
1289
|
+
}
|
|
1290
|
+
updateFromImages(r) {
|
|
1291
|
+
const t = this.pages.getCurrentPageIndex();
|
|
1292
|
+
this.pages.destroy(), this.pages = new y(this, this.render, r), this.pages.load(), this.pages.show(t), this.trigger("update", this, {
|
|
1293
|
+
page: t,
|
|
1294
|
+
mode: this.render.getOrientation()
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
updateFromHtml(r) {
|
|
1298
|
+
const t = this.pages.getCurrentPageIndex();
|
|
1299
|
+
this.pages.destroy(), this.pages = new P(this, this.render, this.ui.getDistElement(), r), this.pages.load(), this.ui.updateItems(r), this.render.reload(), this.pages.show(t), this.trigger("update", this, {
|
|
1300
|
+
page: t,
|
|
1301
|
+
mode: this.render.getOrientation()
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
clear() {
|
|
1305
|
+
this.pages.destroy(), this.ui.clear();
|
|
1306
|
+
}
|
|
1307
|
+
turnToPrevPage() {
|
|
1308
|
+
this.pages.showPrev();
|
|
1309
|
+
}
|
|
1310
|
+
turnToNextPage() {
|
|
1311
|
+
this.pages.showNext();
|
|
1312
|
+
}
|
|
1313
|
+
turnToPage(r) {
|
|
1314
|
+
this.pages.show(r);
|
|
1315
|
+
}
|
|
1316
|
+
flipNext(r = "top") {
|
|
1317
|
+
this.flipController.flipNext(r);
|
|
1318
|
+
}
|
|
1319
|
+
flipPrev(r = "top") {
|
|
1320
|
+
this.flipController.flipPrev(r);
|
|
1321
|
+
}
|
|
1322
|
+
flip(r, t = "top") {
|
|
1323
|
+
this.flipController.flipToPage(r, t);
|
|
1324
|
+
}
|
|
1325
|
+
updateState(r) {
|
|
1326
|
+
this.trigger("changeState", this, r);
|
|
1327
|
+
}
|
|
1328
|
+
updatePageIndex(r) {
|
|
1329
|
+
this.trigger("flip", this, r);
|
|
1330
|
+
}
|
|
1331
|
+
updateOrientation(r) {
|
|
1332
|
+
this.ui.setOrientationStyle(r), this.update(), this.trigger("changeOrientation", this, r);
|
|
1333
|
+
}
|
|
1334
|
+
getPageCount() {
|
|
1335
|
+
return this.pages.getPageCount();
|
|
1336
|
+
}
|
|
1337
|
+
getCurrentPageIndex() {
|
|
1338
|
+
return this.pages.getCurrentPageIndex();
|
|
1339
|
+
}
|
|
1340
|
+
getPage(r) {
|
|
1341
|
+
return this.pages.getPage(r);
|
|
1342
|
+
}
|
|
1343
|
+
getRender() {
|
|
1344
|
+
return this.render;
|
|
1345
|
+
}
|
|
1346
|
+
getFlipController() {
|
|
1347
|
+
return this.flipController;
|
|
1348
|
+
}
|
|
1349
|
+
getOrientation() {
|
|
1350
|
+
return this.render.getOrientation();
|
|
1351
|
+
}
|
|
1352
|
+
getBoundsRect() {
|
|
1353
|
+
return this.render.getRect();
|
|
1354
|
+
}
|
|
1355
|
+
getSettings() {
|
|
1356
|
+
return this.setting;
|
|
1357
|
+
}
|
|
1358
|
+
getUI() {
|
|
1359
|
+
return this.ui;
|
|
1360
|
+
}
|
|
1361
|
+
getState() {
|
|
1362
|
+
return this.flipController.getState();
|
|
1363
|
+
}
|
|
1364
|
+
getPageCollection() {
|
|
1365
|
+
return this.pages;
|
|
1366
|
+
}
|
|
1367
|
+
startUserTouch(r) {
|
|
1368
|
+
this.mousePosition = r, this.isUserTouch = !0, this.isUserMove = !1;
|
|
1369
|
+
}
|
|
1370
|
+
userMove(r, t) {
|
|
1371
|
+
this.isUserTouch || t || !this.setting.showPageCorners ? this.isUserTouch && l.GetDistanceBetweenTwoPoint(this.mousePosition, r) > 5 && (this.isUserMove = !0, this.flipController.fold(r)) : this.flipController.showCorner(r);
|
|
1372
|
+
}
|
|
1373
|
+
userStop(r, t = !1) {
|
|
1374
|
+
this.isUserTouch && (this.isUserTouch = !1, t || (this.isUserMove ? this.flipController.stopMove() : this.flipController.flip(r)));
|
|
1375
|
+
}
|
|
1376
|
+
}, Object.defineProperty(u, "__esModule", { value: !0 });
|
|
1377
|
+
}));
|
|
1378
|
+
})), H = E();
|
|
1379
|
+
export {
|
|
1380
|
+
H as default
|
|
1381
|
+
};
|