postext-folio 0.52.6 → 0.52.8
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/postext/book.d.ts +35 -0
- package/dist/postext/book.d.ts.map +1 -0
- package/dist/postext/book.js +96 -0
- package/dist/postext/book.js.map +1 -0
- package/dist/postext/constants.d.ts +36 -0
- package/dist/postext/constants.d.ts.map +1 -0
- package/dist/postext/constants.js +13 -0
- package/dist/postext/constants.js.map +1 -0
- package/dist/postext/pageVideos.d.ts +26 -0
- package/dist/postext/pageVideos.d.ts.map +1 -0
- package/dist/postext/pageVideos.js +276 -0
- package/dist/postext/pageVideos.js.map +1 -0
- package/dist/postext/painting.d.ts +30 -0
- package/dist/postext/painting.d.ts.map +1 -0
- package/dist/postext/painting.js +167 -0
- package/dist/postext/painting.js.map +1 -0
- package/dist/postext/sharp.d.ts +19 -0
- package/dist/postext/sharp.d.ts.map +1 -0
- package/dist/postext/sharp.js +121 -0
- package/dist/postext/sharp.js.map +1 -0
- package/dist/postext/state.d.ts +29 -0
- package/dist/postext/state.d.ts.map +1 -0
- package/dist/postext/state.js +2 -0
- package/dist/postext/state.js.map +1 -0
- package/dist/postext/sweep.d.ts +24 -0
- package/dist/postext/sweep.d.ts.map +1 -0
- package/dist/postext/sweep.js +37 -0
- package/dist/postext/sweep.js.map +1 -0
- package/dist/postext/types.d.ts +77 -0
- package/dist/postext/types.d.ts.map +1 -0
- package/dist/postext/types.js +2 -0
- package/dist/postext/types.js.map +1 -0
- package/dist/postext.d.ts +6 -124
- package/dist/postext.d.ts.map +1 -1
- package/dist/postext.js +87 -732
- package/dist/postext.js.map +1 -1
- package/dist/viewer/constants.d.ts +30 -0
- package/dist/viewer/constants.d.ts.map +1 -0
- package/dist/viewer/constants.js +49 -0
- package/dist/viewer/constants.js.map +1 -0
- package/dist/viewer/input.d.ts +15 -0
- package/dist/viewer/input.d.ts.map +1 -0
- package/dist/viewer/input.js +142 -0
- package/dist/viewer/input.js.map +1 -0
- package/dist/viewer/layout.d.ts +24 -0
- package/dist/viewer/layout.d.ts.map +1 -0
- package/dist/viewer/layout.js +183 -0
- package/dist/viewer/layout.js.map +1 -0
- package/dist/viewer/lens.d.ts +42 -0
- package/dist/viewer/lens.d.ts.map +1 -0
- package/dist/viewer/lens.js +166 -0
- package/dist/viewer/lens.js.map +1 -0
- package/dist/viewer/pointer.d.ts +37 -0
- package/dist/viewer/pointer.d.ts.map +1 -0
- package/dist/viewer/pointer.js +250 -0
- package/dist/viewer/pointer.js.map +1 -0
- package/dist/viewer/state.d.ts +70 -0
- package/dist/viewer/state.d.ts.map +1 -0
- package/dist/viewer/state.js +2 -0
- package/dist/viewer/state.js.map +1 -0
- package/dist/viewer/turning.d.ts +34 -0
- package/dist/viewer/turning.d.ts.map +1 -0
- package/dist/viewer/turning.js +156 -0
- package/dist/viewer/turning.js.map +1 -0
- package/dist/viewer/types.d.ts +241 -0
- package/dist/viewer/types.d.ts.map +1 -0
- package/dist/viewer/types.js +2 -0
- package/dist/viewer/types.js.map +1 -0
- package/dist/viewer.d.ts +3 -242
- package/dist/viewer.d.ts.map +1 -1
- package/dist/viewer.js +104 -976
- package/dist/viewer.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FolioOptions } from './types.js';
|
|
2
|
+
import type { Spread } from '../spreads.js';
|
|
3
|
+
import type { FolioViewerState, FolioViewerLate } from './state.js';
|
|
4
|
+
/** What createFolioLens takes from createFolio. */
|
|
5
|
+
export interface FolioLensDeps {
|
|
6
|
+
options: FolioOptions;
|
|
7
|
+
root: HTMLDivElement;
|
|
8
|
+
spreadEl: HTMLDivElement;
|
|
9
|
+
rtl: () => boolean;
|
|
10
|
+
pagesOf: (s: Spread | undefined) => number[];
|
|
11
|
+
aspect: () => number;
|
|
12
|
+
go: (index: number) => void;
|
|
13
|
+
vs: FolioViewerState;
|
|
14
|
+
vlate: FolioViewerLate;
|
|
15
|
+
}
|
|
16
|
+
export declare function createFolioLens(deps: FolioLensDeps): {
|
|
17
|
+
zoomNow: () => number;
|
|
18
|
+
lensOf: (at: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}) => {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
radius: number;
|
|
25
|
+
rim: number;
|
|
26
|
+
zoom: number;
|
|
27
|
+
};
|
|
28
|
+
heldAt: (event: {
|
|
29
|
+
clientX: number;
|
|
30
|
+
clientY: number;
|
|
31
|
+
pointerType?: string;
|
|
32
|
+
}) => {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
};
|
|
36
|
+
raiseLens: () => void;
|
|
37
|
+
hideLens: () => void;
|
|
38
|
+
zoomBy: (factor: number) => void;
|
|
39
|
+
scheduleDetail: (delay: number) => void;
|
|
40
|
+
releaseLens: () => void;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=lens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.d.ts","sourceRoot":"","sources":["../../src/viewer/lens.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,MAAM,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,EAAE,CAAC;IAC7C,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,EAAE,EAAE,gBAAgB,CAAC;IACrB,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa;mBAc7B,MAAM;iBAKN;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;oBAQrB;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;;;qBA0BpF,MAAM;4BA+BC,MAAM;;EA+DtC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The folio viewer's magnifying glass (#527): where it is held, its zoom and
|
|
2
|
+
// the sharper paintings it asks for (#1276: split out of viewer.ts).
|
|
3
|
+
import { clamp, ZOOM_MIN, ZOOM_MAX, LENS_PX_PER_MM, sourceOf, SWIPE } from './constants.js';
|
|
4
|
+
export function createFolioLens(deps) {
|
|
5
|
+
const { options, root, spreadEl, rtl, pagesOf, aspect, go, vs, vlate } = deps;
|
|
6
|
+
// ── The magnifying glass (#527) ──
|
|
7
|
+
/** Where the glass is held (client px), when it is. */
|
|
8
|
+
vs.lensAt = null;
|
|
9
|
+
vs.lensZoom = options.magnifier?.zoom ? clamp(options.magnifier.zoom, ZOOM_MIN, ZOOM_MAX) : null;
|
|
10
|
+
/** Page source → its sharper painting, and the width each was asked
|
|
11
|
+
* for at. */
|
|
12
|
+
vs.details = new Map();
|
|
13
|
+
vs.detailAsked = new Map();
|
|
14
|
+
vs.detailTimer = 0;
|
|
15
|
+
function zoomNow() {
|
|
16
|
+
if (vs.lensZoom)
|
|
17
|
+
return vs.lensZoom;
|
|
18
|
+
const perMm = vs.slot.width / (vs.appearance.pageWidthMm ?? 150);
|
|
19
|
+
return perMm > 0 ? clamp(LENS_PX_PER_MM / perMm, 2, 8) : 3;
|
|
20
|
+
}
|
|
21
|
+
function lensOf(at) {
|
|
22
|
+
const box = root.getBoundingClientRect();
|
|
23
|
+
const diameter = options.magnifier?.diameter ?? clamp(0.42 * Math.min(box.width, box.height), 180, 520);
|
|
24
|
+
const rim = clamp(diameter * 0.045, 8, 18);
|
|
25
|
+
return { x: at.x, y: at.y, radius: diameter / 2 - rim, rim, zoom: zoomNow() };
|
|
26
|
+
}
|
|
27
|
+
/** Where the glass is held for a pointer: under a mouse or a pen, but
|
|
28
|
+
* a finger holds it above itself, where it does not hide it. */
|
|
29
|
+
function heldAt(event) {
|
|
30
|
+
if (event.pointerType !== "touch")
|
|
31
|
+
return { x: event.clientX, y: event.clientY };
|
|
32
|
+
const lens = lensOf({ x: event.clientX, y: event.clientY });
|
|
33
|
+
return { x: lens.x, y: lens.y - (lens.radius + lens.rim + 28) };
|
|
34
|
+
}
|
|
35
|
+
function placeLens(event) {
|
|
36
|
+
if (!vs.flipper)
|
|
37
|
+
return;
|
|
38
|
+
const lens = lensOf(heldAt(event));
|
|
39
|
+
vs.lensAt = { x: lens.x, y: lens.y };
|
|
40
|
+
root.classList.add("is-magnifying");
|
|
41
|
+
vs.flipper.setLens(lens);
|
|
42
|
+
}
|
|
43
|
+
/** Without a pointer to hold it (the keyboard, a host), the glass comes
|
|
44
|
+
* up over the spread's centre. */
|
|
45
|
+
function raiseLens() {
|
|
46
|
+
if (vs.lensAt)
|
|
47
|
+
return;
|
|
48
|
+
const r = spreadEl.getBoundingClientRect();
|
|
49
|
+
vs.lensAt = { x: r.left + r.width / 2, y: r.top + r.height / 2 };
|
|
50
|
+
root.classList.add("is-magnifying");
|
|
51
|
+
}
|
|
52
|
+
function hideLens() {
|
|
53
|
+
if (!vs.lensAt)
|
|
54
|
+
return;
|
|
55
|
+
vs.lensAt = null;
|
|
56
|
+
root.classList.remove("is-magnifying");
|
|
57
|
+
vs.flipper?.setLens(null);
|
|
58
|
+
}
|
|
59
|
+
function zoomBy(factor) {
|
|
60
|
+
vs.lensZoom = clamp(zoomNow() * factor, ZOOM_MIN, ZOOM_MAX);
|
|
61
|
+
if (vs.lensAt)
|
|
62
|
+
vs.flipper?.setLens(lensOf(vs.lensAt));
|
|
63
|
+
scheduleDetail(250);
|
|
64
|
+
}
|
|
65
|
+
root.addEventListener("pointermove", (event) => {
|
|
66
|
+
if (vs.interaction !== "magnify" || vs.holding)
|
|
67
|
+
return;
|
|
68
|
+
if (event.pointerType === "touch" && !event.buttons)
|
|
69
|
+
return;
|
|
70
|
+
placeLens(event);
|
|
71
|
+
});
|
|
72
|
+
root.addEventListener("pointerdown", (event) => {
|
|
73
|
+
if (vs.interaction !== "magnify" || event.button !== 0)
|
|
74
|
+
return;
|
|
75
|
+
if (event.target.closest(".postext-folio-nav"))
|
|
76
|
+
return;
|
|
77
|
+
placeLens(event);
|
|
78
|
+
});
|
|
79
|
+
for (const type of ["pointerup", "pointercancel"]) {
|
|
80
|
+
root.addEventListener(type, (event) => {
|
|
81
|
+
if (event.pointerType === "touch")
|
|
82
|
+
hideLens();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
root.addEventListener("wheel", (event) => {
|
|
86
|
+
if (vs.interaction !== "magnify" || !vs.flipper)
|
|
87
|
+
return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
const delta = event.deltaMode === 1 ? event.deltaY * 16 : event.deltaY;
|
|
90
|
+
zoomBy(Math.exp(-delta * 0.0015));
|
|
91
|
+
}, { passive: false });
|
|
92
|
+
function scheduleDetail(delay) {
|
|
93
|
+
if (vs.interaction !== "magnify" || !options.detail)
|
|
94
|
+
return;
|
|
95
|
+
clearTimeout(vs.detailTimer);
|
|
96
|
+
vs.detailTimer = window.setTimeout(askDetail, delay);
|
|
97
|
+
}
|
|
98
|
+
/** Asks the host for the open pages painted sharp enough for the glass
|
|
99
|
+
* (a texel for each screen pixel at its centre, within the largest
|
|
100
|
+
* texture the book shows), and lets go of the others' paintings. */
|
|
101
|
+
function askDetail() {
|
|
102
|
+
const host = options.detail;
|
|
103
|
+
const flip = vs.flipper;
|
|
104
|
+
if (vs.interaction !== "magnify" || !host || !flip || !vs.slot.deviceWidth || vs.disposed)
|
|
105
|
+
return;
|
|
106
|
+
const cap = flip.maxTextureSize;
|
|
107
|
+
const want = Math.max(vs.slot.deviceWidth, Math.min(cap, Math.floor(cap * aspect()), Math.ceil((vs.slot.deviceWidth * zoomNow()) / 256) * 256));
|
|
108
|
+
const on = new Map();
|
|
109
|
+
for (const i of new Set([...pagesOf(vs.spreads[vs.shown]), ...pagesOf(vs.spreads[vs.current])])) {
|
|
110
|
+
const src = sourceOf(vs.pages[i]);
|
|
111
|
+
if (src)
|
|
112
|
+
on.set(src, i);
|
|
113
|
+
}
|
|
114
|
+
for (const src of [...vs.details.keys()])
|
|
115
|
+
if (!on.has(src))
|
|
116
|
+
vs.details.delete(src);
|
|
117
|
+
for (const src of [...vs.detailAsked.keys()])
|
|
118
|
+
if (!on.has(src))
|
|
119
|
+
vs.detailAsked.delete(src);
|
|
120
|
+
flip.setDetail(vs.details);
|
|
121
|
+
for (const [src, i] of on) {
|
|
122
|
+
if ((vs.detailAsked.get(src) ?? 0) >= want)
|
|
123
|
+
continue;
|
|
124
|
+
vs.detailAsked.set(src, want);
|
|
125
|
+
void Promise.resolve(host.paint(i, want)).then((painting) => {
|
|
126
|
+
if (!painting || vs.flipper !== flip || vs.interaction !== "magnify" || sourceOf(vs.pages[i]) !== src)
|
|
127
|
+
return;
|
|
128
|
+
vs.details.set(src, painting);
|
|
129
|
+
flip.setDetail(vs.details);
|
|
130
|
+
}, () => vs.detailAsked.delete(src));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Puts the glass away and lets go of its paintings. */
|
|
134
|
+
function releaseLens() {
|
|
135
|
+
hideLens();
|
|
136
|
+
clearTimeout(vs.detailTimer);
|
|
137
|
+
if (!vs.details.size && !vs.detailAsked.size)
|
|
138
|
+
return;
|
|
139
|
+
vs.details = new Map();
|
|
140
|
+
vs.detailAsked = new Map();
|
|
141
|
+
vs.flipper?.setDetail(vs.details);
|
|
142
|
+
options.detail?.release?.();
|
|
143
|
+
}
|
|
144
|
+
root.addEventListener("pointerdown", (event) => {
|
|
145
|
+
// Only the hand takes pages, swipes and clicks them over.
|
|
146
|
+
if (vs.interaction !== "hand")
|
|
147
|
+
return;
|
|
148
|
+
if (vlate.onPage(event))
|
|
149
|
+
return;
|
|
150
|
+
if (event.pointerType !== "mouse")
|
|
151
|
+
vs.swipe = { x: event.clientX, y: event.clientY };
|
|
152
|
+
});
|
|
153
|
+
root.addEventListener("pointerup", (event) => {
|
|
154
|
+
const start = vs.swipe;
|
|
155
|
+
vs.swipe = null;
|
|
156
|
+
if (!start)
|
|
157
|
+
return;
|
|
158
|
+
const dx = event.clientX - start.x;
|
|
159
|
+
if (Math.abs(dx) > SWIPE && Math.abs(dx) > Math.abs(event.clientY - start.y))
|
|
160
|
+
go(vs.current + ((dx < 0) !== rtl() ? 1 : -1));
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
zoomNow, lensOf, heldAt, raiseLens, hideLens, zoomBy, scheduleDetail, releaseLens
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=lens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.js","sourceRoot":"","sources":["../../src/viewer/lens.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qEAAqE;AACrE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAmB5F,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,MAAM,EACJ,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAC7D,GAAG,IAAI,CAAC;IACT,oCAAoC;IACpC,uDAAuD;IACvD,EAAE,CAAC,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E,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW;KAClF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FolioPagePoint, FolioOptions } from './types.js';
|
|
2
|
+
import type { FolioViewerState } from './state.js';
|
|
3
|
+
/** What createFolioPointer takes from createFolio. */
|
|
4
|
+
export interface FolioPointerDeps {
|
|
5
|
+
options: FolioOptions;
|
|
6
|
+
root: HTMLDivElement;
|
|
7
|
+
spreadEl: HTMLDivElement;
|
|
8
|
+
rtl: () => boolean;
|
|
9
|
+
singleGl: () => boolean;
|
|
10
|
+
go: (index: number) => void;
|
|
11
|
+
heldAt: (event: {
|
|
12
|
+
clientX: number;
|
|
13
|
+
clientY: number;
|
|
14
|
+
pointerType?: string;
|
|
15
|
+
}) => {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
scheduleDetail: (delay: number) => void;
|
|
20
|
+
releaseLens: () => void;
|
|
21
|
+
vs: FolioViewerState;
|
|
22
|
+
}
|
|
23
|
+
export declare function createFolioPointer(deps: FolioPointerDeps): {
|
|
24
|
+
onPage: (event: PointerEvent) => boolean;
|
|
25
|
+
leftToHost: () => boolean;
|
|
26
|
+
aimedPageAt: (event: {
|
|
27
|
+
clientX: number;
|
|
28
|
+
clientY: number;
|
|
29
|
+
pointerType?: string;
|
|
30
|
+
}) => FolioPagePoint | null;
|
|
31
|
+
pointOnScreen: (point: FolioPagePoint) => {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
} | null;
|
|
35
|
+
applyInteraction: () => void;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/viewer/pointer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,MAAM,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;KAAE,KAAK;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;KAAE,CAAC;IAC1G,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,EAAE,EAAE,gBAAgB,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB;oBAOhC,YAAY,KAAG,OAAO;sBA6KtB,OAAO;yBAMF;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG,cAAc,GAAG,IAAI;2BAMhF,cAAc,KAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;;EA0B/E"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// The folio viewer's presses on the pages: taken by hand, a click, a swipe,
|
|
2
|
+
// and where a point lies on a page (#1276: split out of viewer.ts).
|
|
3
|
+
import { CLICK_SLOP, SWIPE } from './constants.js';
|
|
4
|
+
export function createFolioPointer(deps) {
|
|
5
|
+
const { options, root, spreadEl, rtl, singleGl, go, heldAt, scheduleDetail, releaseLens, vs } = deps;
|
|
6
|
+
/** A press on a page: taken by hand (the WebGL book, hit in 3D, since
|
|
7
|
+
* the tilted book does not lie over the DOM spread), or remembered as a
|
|
8
|
+
* possible click. True when the stage's swipe should not hear it. */
|
|
9
|
+
function onPage(event) {
|
|
10
|
+
if (event.button !== 0 || vs.holding)
|
|
11
|
+
return false;
|
|
12
|
+
const target = event.target;
|
|
13
|
+
if (target.closest(".postext-folio-nav"))
|
|
14
|
+
return false;
|
|
15
|
+
if (vs.flipper ? !vs.flipper.hit(event) : !target.closest(".postext-folio-spread"))
|
|
16
|
+
return false;
|
|
17
|
+
vs.press = { x: event.clientX, y: event.clientY };
|
|
18
|
+
// Where it was pressed, read before the hand lifts the leaf.
|
|
19
|
+
vs.pressPoint = options.onPageClick ? pageAt(event) : null;
|
|
20
|
+
if (singleGl()) {
|
|
21
|
+
decide(event);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (!vs.flipper?.grab(event))
|
|
25
|
+
return false;
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
hold(event, vs.press);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One page at a time, the page is taken only once the pointer shows
|
|
32
|
+
* which way it goes: towards the spine it is lifted and dragged over
|
|
33
|
+
* (from where it was pressed), away from it the book goes back a page (a
|
|
34
|
+
* swipe); a press that does not move is a tap and turns forward.
|
|
35
|
+
*/
|
|
36
|
+
function decide(down) {
|
|
37
|
+
down.stopPropagation();
|
|
38
|
+
vs.swipe = null;
|
|
39
|
+
const id = down.pointerId;
|
|
40
|
+
const start = { x: down.clientX, y: down.clientY };
|
|
41
|
+
const toSpine = rtl() ? 1 : -1;
|
|
42
|
+
const done = () => {
|
|
43
|
+
window.removeEventListener("pointermove", onMove);
|
|
44
|
+
window.removeEventListener("pointerup", onUp, true);
|
|
45
|
+
window.removeEventListener("pointercancel", onCancel);
|
|
46
|
+
};
|
|
47
|
+
const onMove = (e) => {
|
|
48
|
+
if (e.pointerId !== id)
|
|
49
|
+
return;
|
|
50
|
+
const dx = e.clientX - start.x;
|
|
51
|
+
const dy = e.clientY - start.y;
|
|
52
|
+
if (Math.hypot(dx, dy) < CLICK_SLOP || Math.abs(dy) > Math.abs(dx))
|
|
53
|
+
return;
|
|
54
|
+
if (Math.sign(dx) !== toSpine)
|
|
55
|
+
return; // a swipe back: settled on release
|
|
56
|
+
done();
|
|
57
|
+
if (!vs.flipper?.grab(down))
|
|
58
|
+
return;
|
|
59
|
+
hold(down, start);
|
|
60
|
+
vs.flipper.drag(e);
|
|
61
|
+
};
|
|
62
|
+
const onUp = (e) => {
|
|
63
|
+
if (e.pointerId !== id)
|
|
64
|
+
return;
|
|
65
|
+
done();
|
|
66
|
+
vs.press = null;
|
|
67
|
+
const dx = e.clientX - start.x;
|
|
68
|
+
const dy = e.clientY - start.y;
|
|
69
|
+
if (Math.hypot(dx, dy) < CLICK_SLOP) {
|
|
70
|
+
if (!pageClick())
|
|
71
|
+
go(vs.current + 1);
|
|
72
|
+
}
|
|
73
|
+
else if (Math.abs(dx) > SWIPE && Math.abs(dx) > Math.abs(dy) && Math.sign(dx) === -toSpine)
|
|
74
|
+
go(vs.current - 1);
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
};
|
|
77
|
+
const onCancel = (e) => {
|
|
78
|
+
if (e.pointerId === id)
|
|
79
|
+
done();
|
|
80
|
+
};
|
|
81
|
+
window.addEventListener("pointermove", onMove);
|
|
82
|
+
window.addEventListener("pointerup", onUp, true);
|
|
83
|
+
window.addEventListener("pointercancel", onCancel);
|
|
84
|
+
}
|
|
85
|
+
/** Holds the page taken at `event` until the pointer lets go. */
|
|
86
|
+
function hold(event, start) {
|
|
87
|
+
// The hold follows the pointer anywhere: the window hears it even if
|
|
88
|
+
// the capture is lost, and a move with the button up means the release
|
|
89
|
+
// was missed.
|
|
90
|
+
const id = event.pointerId;
|
|
91
|
+
const onMove = (e) => {
|
|
92
|
+
if (e.pointerId !== id)
|
|
93
|
+
return;
|
|
94
|
+
if ((e.buttons & 1) === 0)
|
|
95
|
+
end(false);
|
|
96
|
+
else
|
|
97
|
+
vs.flipper?.drag(e);
|
|
98
|
+
};
|
|
99
|
+
const onUp = (e) => {
|
|
100
|
+
if (e.pointerId === id)
|
|
101
|
+
end(Math.hypot(e.clientX - start.x, e.clientY - start.y) < CLICK_SLOP);
|
|
102
|
+
};
|
|
103
|
+
const onCancel = (e) => {
|
|
104
|
+
if (e.pointerId === id)
|
|
105
|
+
end(false);
|
|
106
|
+
};
|
|
107
|
+
const onBlur = () => end(false);
|
|
108
|
+
const end = (click) => {
|
|
109
|
+
window.removeEventListener("pointermove", onMove);
|
|
110
|
+
window.removeEventListener("pointerup", onUp, true);
|
|
111
|
+
window.removeEventListener("pointercancel", onCancel);
|
|
112
|
+
window.removeEventListener("blur", onBlur);
|
|
113
|
+
spreadEl.classList.remove("is-held");
|
|
114
|
+
vs.holding = null;
|
|
115
|
+
vs.press = null;
|
|
116
|
+
// A click that acts on the page (a video) lets the leaf fall back.
|
|
117
|
+
vs.flipper?.release(click && !pageClick());
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener("pointermove", onMove);
|
|
120
|
+
// Captured, so the stage's swipe does not hear the hold's release.
|
|
121
|
+
window.addEventListener("pointerup", onUp, true);
|
|
122
|
+
window.addEventListener("pointercancel", onCancel);
|
|
123
|
+
window.addEventListener("blur", onBlur);
|
|
124
|
+
vs.holding = end;
|
|
125
|
+
vs.swipe = null;
|
|
126
|
+
spreadEl.classList.add("is-held");
|
|
127
|
+
try {
|
|
128
|
+
spreadEl.setPointerCapture(id);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// The window listeners carry the hold without it.
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
root.addEventListener("pointerup", (event) => {
|
|
135
|
+
if (vs.holding || singleGl() || vs.interaction !== "hand")
|
|
136
|
+
return;
|
|
137
|
+
const start = vs.press;
|
|
138
|
+
vs.press = null;
|
|
139
|
+
const click = !!start && Math.hypot(event.clientX - start.x, event.clientY - start.y) < CLICK_SLOP;
|
|
140
|
+
if (!click)
|
|
141
|
+
return;
|
|
142
|
+
if (pageClick()) {
|
|
143
|
+
vs.swipe = null;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// A click on the recto turns forward, on the verso back (pages already
|
|
147
|
+
// in the air: it joins them).
|
|
148
|
+
if (vs.flipper) {
|
|
149
|
+
const side = vs.flipper.hit(event);
|
|
150
|
+
if (!side)
|
|
151
|
+
return;
|
|
152
|
+
vs.swipe = null;
|
|
153
|
+
return go(vs.current + (vs.single ? 1 : side));
|
|
154
|
+
}
|
|
155
|
+
if (!event.target.closest(".postext-folio-page:not(.is-empty)"))
|
|
156
|
+
return;
|
|
157
|
+
const rect = spreadEl.getBoundingClientRect();
|
|
158
|
+
vs.swipe = null;
|
|
159
|
+
if (vs.single)
|
|
160
|
+
go(vs.current + 1);
|
|
161
|
+
else
|
|
162
|
+
go(vs.current + ((event.clientX > rect.left + rect.width / 2) !== rtl() ? 1 : -1));
|
|
163
|
+
});
|
|
164
|
+
/** A click at the point pressed: the host's to act on (true), or the
|
|
165
|
+
* page's to turn. */
|
|
166
|
+
function pageClick() {
|
|
167
|
+
const point = vs.pressPoint;
|
|
168
|
+
vs.pressPoint = null;
|
|
169
|
+
return !!point && !!options.onPageClick?.(point);
|
|
170
|
+
}
|
|
171
|
+
/** The page index in slot `side` (0 the verso, 1 the recto) of the
|
|
172
|
+
* spread on show. */
|
|
173
|
+
const pageInSlot = (side) => {
|
|
174
|
+
const s = vs.spreads[vs.shown];
|
|
175
|
+
if (!s)
|
|
176
|
+
return null;
|
|
177
|
+
return vs.single && !singleGl() ? (s[0] ?? s[1]) : s[side];
|
|
178
|
+
};
|
|
179
|
+
function pageAt(event) {
|
|
180
|
+
if (vs.flipper) {
|
|
181
|
+
const hit = vs.flipper.pagePoint(event);
|
|
182
|
+
if (!hit)
|
|
183
|
+
return null;
|
|
184
|
+
const page = pageInSlot(hit.side);
|
|
185
|
+
return page === null || page === undefined ? null : { page, x: hit.x, y: hit.y };
|
|
186
|
+
}
|
|
187
|
+
// The DOM spread: its pages in slot order (`render`), whatever side
|
|
188
|
+
// the layout puts them on (a right-bound book runs right to left, so
|
|
189
|
+
// its verso stands on the right); each is found by its own box.
|
|
190
|
+
const els = [...spreadEl.children];
|
|
191
|
+
for (let k = 0; k < els.length; k++) {
|
|
192
|
+
const r = els[k].getBoundingClientRect();
|
|
193
|
+
if (event.clientX < r.left || event.clientX > r.right || event.clientY < r.top || event.clientY > r.bottom)
|
|
194
|
+
continue;
|
|
195
|
+
const side = (els.length === 1 ? 1 : k);
|
|
196
|
+
const page = els.length === 1 ? pageInSlot(0) : pageInSlot(side);
|
|
197
|
+
if (page === null || page === undefined)
|
|
198
|
+
return null;
|
|
199
|
+
return { page, x: (event.clientX - r.left) / r.width, y: (event.clientY - r.top) / r.height };
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/** The pointer is the host's to select with (select mode, and under the
|
|
204
|
+
* glass in magnify mode, #543). */
|
|
205
|
+
function leftToHost() {
|
|
206
|
+
return vs.interaction === "select" || vs.interaction === "magnify";
|
|
207
|
+
}
|
|
208
|
+
/** The page point a pointer aims at: under it, or in magnify mode under
|
|
209
|
+
* the glass's centre (#543). */
|
|
210
|
+
function aimedPageAt(event) {
|
|
211
|
+
if (vs.interaction !== "magnify")
|
|
212
|
+
return pageAt(event);
|
|
213
|
+
const at = heldAt(event);
|
|
214
|
+
return pageAt({ clientX: at.x, clientY: at.y });
|
|
215
|
+
}
|
|
216
|
+
function pointOnScreen(point) {
|
|
217
|
+
const s = vs.spreads[vs.shown];
|
|
218
|
+
if (!s)
|
|
219
|
+
return null;
|
|
220
|
+
const found = pageInSlot(1) === point.page ? 1 : pageInSlot(0) === point.page ? 0 : -1;
|
|
221
|
+
if (found < 0)
|
|
222
|
+
return null;
|
|
223
|
+
const side = found;
|
|
224
|
+
if (vs.flipper)
|
|
225
|
+
return vs.flipper.screenPoint(side, point.x, point.y);
|
|
226
|
+
const els = [...spreadEl.children];
|
|
227
|
+
const el = els.length === 1 ? els[0] : els[side];
|
|
228
|
+
if (!el)
|
|
229
|
+
return null;
|
|
230
|
+
const r = el.getBoundingClientRect();
|
|
231
|
+
return { x: r.left + point.x * r.width, y: r.top + point.y * r.height };
|
|
232
|
+
}
|
|
233
|
+
function applyInteraction() {
|
|
234
|
+
root.classList.toggle("is-orbit", vs.interaction === "orbit");
|
|
235
|
+
root.classList.toggle("is-select", vs.interaction === "select");
|
|
236
|
+
root.classList.toggle("is-magnify", vs.interaction === "magnify");
|
|
237
|
+
if (!leftToHost())
|
|
238
|
+
root.classList.remove("is-over-page");
|
|
239
|
+
if (vs.interaction !== "hand")
|
|
240
|
+
root.classList.remove("is-over-grip");
|
|
241
|
+
if (vs.interaction === "magnify")
|
|
242
|
+
scheduleDetail(0);
|
|
243
|
+
else
|
|
244
|
+
releaseLens();
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
onPage, leftToHost, aimedPageAt, pointOnScreen, applyInteraction
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../src/viewer/pointer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AACpE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAkBnD,MAAM,UAAU,kBAAkB,CAAC,IAAsB;IACvD,MAAM,EACJ,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,EACpF,GAAG,IAAI,CAAC;IACT;;0EAEsE;IACtE,SAAS,MAAM,C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,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC;QAClE,IAAI,CAAC,UAAU,EAAE;YAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,WAAW,KAAK,MAAM;YAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACrE,IAAI,EAAE,CAAC,WAAW,KAAK,SAAS;YAAE,cAAc,CAAC,CAAC,CAAC,CAAC;;YAC/C,WAAW,EAAE,CAAC;IACrB,CAAC;IACD,OAAO;QACL,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB;KACjE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { FolioLabels, FolioPage, FolioAppearance, FolioInteraction, FolioPageSize, FolioPageVideo, FolioPagePoint } from './types.js';
|
|
2
|
+
import type { Spread } from '../spreads.js';
|
|
3
|
+
import { PageFlipper, type PageSource } from '../pageFlip.js';
|
|
4
|
+
/** The bindings the folio viewer reassigns and more than one of its modules
|
|
5
|
+
* reads or writes: fields of one object. */
|
|
6
|
+
export interface FolioViewerState {
|
|
7
|
+
labels: FolioLabels;
|
|
8
|
+
pages: FolioPage[];
|
|
9
|
+
firstPageRecto: boolean;
|
|
10
|
+
binding: "left" | "right";
|
|
11
|
+
mode: "auto" | "single" | "double";
|
|
12
|
+
paper: string;
|
|
13
|
+
appearance: FolioAppearance;
|
|
14
|
+
appearanceKey: string;
|
|
15
|
+
interaction: FolioInteraction;
|
|
16
|
+
single: boolean;
|
|
17
|
+
spreads: Spread[];
|
|
18
|
+
current: number;
|
|
19
|
+
shown: number;
|
|
20
|
+
flipper: PageFlipper | null;
|
|
21
|
+
flipCanvas: HTMLCanvasElement | null;
|
|
22
|
+
holding: ((click: boolean) => void) | null;
|
|
23
|
+
press: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | null;
|
|
27
|
+
swipe: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
} | null;
|
|
31
|
+
disposed: boolean;
|
|
32
|
+
slot: FolioPageSize;
|
|
33
|
+
pageVideos: FolioPageVideo[];
|
|
34
|
+
pressPoint: FolioPagePoint | null;
|
|
35
|
+
lensAt: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
lensZoom: number | null;
|
|
40
|
+
details: Map<PageSource, PageSource>;
|
|
41
|
+
detailAsked: Map<PageSource, number>;
|
|
42
|
+
detailTimer: number;
|
|
43
|
+
}
|
|
44
|
+
/** What a module of the folio viewer calls before the viewer has made it:
|
|
45
|
+
* filled as soon as each one exists. */
|
|
46
|
+
export interface FolioViewerLate {
|
|
47
|
+
placeDomVideo: () => void;
|
|
48
|
+
lensOf: (at: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
}) => {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
radius: number;
|
|
55
|
+
rim: number;
|
|
56
|
+
zoom: number;
|
|
57
|
+
};
|
|
58
|
+
raiseLens: () => void;
|
|
59
|
+
hideLens: () => void;
|
|
60
|
+
zoomBy: (factor: number) => void;
|
|
61
|
+
scheduleDetail: (delay: number) => void;
|
|
62
|
+
onPage: (event: PointerEvent) => boolean;
|
|
63
|
+
leftToHost: () => boolean;
|
|
64
|
+
aimedPageAt: (event: {
|
|
65
|
+
clientX: number;
|
|
66
|
+
clientY: number;
|
|
67
|
+
pointerType?: string;
|
|
68
|
+
}) => FolioPagePoint | null;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/viewer/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,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|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FolioPageVideo, FolioOptions } from './types.js';
|
|
2
|
+
import { type SpreadSrc, type FlipAppearance } from '../pageFlip.js';
|
|
3
|
+
import { type Spread } from '../spreads.js';
|
|
4
|
+
import type { FolioViewerState, FolioViewerLate } from './state.js';
|
|
5
|
+
/** What createFolioTurning takes from createFolio. */
|
|
6
|
+
export interface FolioTurningDeps {
|
|
7
|
+
options: FolioOptions;
|
|
8
|
+
animate: boolean;
|
|
9
|
+
root: HTMLDivElement;
|
|
10
|
+
prevBtn: HTMLButtonElement;
|
|
11
|
+
nextBtn: HTMLButtonElement;
|
|
12
|
+
spreadEl: HTMLDivElement;
|
|
13
|
+
count: HTMLParagraphElement;
|
|
14
|
+
rtl: () => boolean;
|
|
15
|
+
pagesOf: (s: Spread | undefined) => number[];
|
|
16
|
+
singleGl: () => boolean;
|
|
17
|
+
bookOf: () => SpreadSrc[];
|
|
18
|
+
flipAppearance: () => FlipAppearance;
|
|
19
|
+
fit: () => void;
|
|
20
|
+
pageEl: (i: number | null, slot: 0 | 1) => HTMLDivElement;
|
|
21
|
+
vs: FolioViewerState;
|
|
22
|
+
vlate: FolioViewerLate;
|
|
23
|
+
}
|
|
24
|
+
export declare function createFolioTurning(deps: FolioTurningDeps): {
|
|
25
|
+
applyVideo: () => void;
|
|
26
|
+
unplace: (v: FolioPageVideo) => void;
|
|
27
|
+
placeDomVideo: () => void;
|
|
28
|
+
render: () => void;
|
|
29
|
+
go: (index: number) => void;
|
|
30
|
+
jump: (index: number) => void;
|
|
31
|
+
rebuild: (atPage: number) => void;
|
|
32
|
+
applyLabels: () => void;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=turning.d.ts.map
|