-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote_flipbook.html
More file actions
215 lines (203 loc) · 6.03 KB
/
Copy pathnote_flipbook.html
File metadata and controls
215 lines (203 loc) · 6.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Daily Logs Flipbook</title>
<style>
:root { --accent: #157878; }
* { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
background: #1c1c1c;
font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
color: #fff;
-webkit-tap-highlight-color: transparent;
}
.book-wrap {
max-width: 640px;
margin: 0 auto;
padding: 14px 12px 18px;
}
.stage {
position: relative;
width: 100%;
/* journal pages are roughly portrait; keep a stable aspect box */
aspect-ratio: 3 / 4;
background: #2a2a2a;
border-radius: 6px;
overflow: hidden;
box-shadow: 0 10px 30px rgba(0,0,0,.45);
perspective: 1600px;
}
.page-img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: contain;
background: #fff;
opacity: 0;
transform: rotateY(-12deg);
transition: opacity .28s ease, transform .28s ease;
pointer-events: none;
}
.page-img.is-current {
opacity: 1;
transform: rotateY(0deg);
pointer-events: auto;
}
/* invisible click zones for prev/next */
.tap {
position: absolute;
top: 0;
bottom: 0;
width: 38%;
z-index: 5;
cursor: pointer;
border: 0;
background: transparent;
padding: 0;
}
.tap.prev { left: 0; }
.tap.next { right: 0; }
.spinner {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
color: #aaa;
}
.controls {
display: flex;
align-items: center;
justify-content: center;
gap: 14px;
margin-top: 12px;
}
.controls button {
appearance: none;
border: 0;
background: var(--accent);
color: #fff;
font-size: 15px;
font-weight: 700;
padding: 9px 18px;
border-radius: 999px;
cursor: pointer;
transition: filter .15s ease, transform .05s ease;
}
.controls button:hover { filter: brightness(1.12); }
.controls button:active { transform: translateY(1px); }
.controls button:disabled {
opacity: .35;
cursor: not-allowed;
filter: none;
}
.counter {
min-width: 72px;
text-align: center;
font-variant-numeric: tabular-nums;
font-size: 14px;
color: #ddd;
}
.hint {
text-align: center;
margin: 10px 0 0;
font-size: 12px;
color: #888;
}
@media (max-width: 480px) {
.controls button { padding: 9px 14px; font-size: 14px; }
}
</style>
</head>
<body>
<div class="book-wrap">
<div class="stage" id="stage">
<div class="spinner" id="spinner">Loading journal…</div>
<button class="tap prev" id="tapPrev" aria-label="Previous page"></button>
<button class="tap next" id="tapNext" aria-label="Next page"></button>
</div>
<div class="controls">
<button id="btnPrev" aria-label="Previous page">‹ Prev</button>
<span class="counter" id="counter">1 / 45</span>
<button id="btnNext" aria-label="Next page">Next ›</button>
</div>
<p class="hint">Use the buttons, arrow keys, tap the sides, or swipe.</p>
</div>
<script>
(function () {
var TOTAL = 45;
var stage = document.getElementById('stage');
var spinner = document.getElementById('spinner');
var counter = document.getElementById('counter');
var btnPrev = document.getElementById('btnPrev');
var btnNext = document.getElementById('btnNext');
var tapPrev = document.getElementById('tapPrev');
var tapNext = document.getElementById('tapNext');
var imgs = [];
var current = 0;
var loaded = {};
function srcFor(i) { return 'images/Page' + (i + 1) + '.jpg'; }
function ensureLoaded(i) {
if (i < 0 || i >= TOTAL || loaded[i]) return;
loaded[i] = true;
var el = imgs[i];
el.src = srcFor(i);
}
// build the image elements lazily
for (var i = 0; i < TOTAL; i++) {
var img = document.createElement('img');
img.className = 'page-img';
img.alt = 'Journal page ' + (i + 1);
img.decoding = 'async';
stage.appendChild(img);
imgs.push(img);
}
function render() {
for (var i = 0; i < TOTAL; i++) {
imgs[i].classList.toggle('is-current', i === current);
}
// preload current + neighbours
ensureLoaded(current);
ensureLoaded(current + 1);
ensureLoaded(current - 1);
counter.textContent = (current + 1) + ' / ' + TOTAL;
btnPrev.disabled = tapPrev.disabled = current === 0;
btnNext.disabled = tapNext.disabled = current === TOTAL - 1;
if (spinner) { spinner.style.display = 'none'; }
}
function go(delta) {
var next = Math.min(TOTAL - 1, Math.max(0, current + delta));
if (next === current) return;
current = next;
render();
}
btnPrev.addEventListener('click', function () { go(-1); });
btnNext.addEventListener('click', function () { go(1); });
tapPrev.addEventListener('click', function () { go(-1); });
tapNext.addEventListener('click', function () { go(1); });
document.addEventListener('keydown', function (e) {
if (e.key === 'ArrowLeft') { go(-1); }
else if (e.key === 'ArrowRight') { go(1); }
});
// touch swipe
var startX = null;
stage.addEventListener('touchstart', function (e) {
startX = e.touches[0].clientX;
}, { passive: true });
stage.addEventListener('touchend', function (e) {
if (startX === null) return;
var dx = e.changedTouches[0].clientX - startX;
if (Math.abs(dx) > 40) { go(dx < 0 ? 1 : -1); }
startX = null;
}, { passive: true });
render();
})();
</script>
</body>
</html>