Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -100,19 +100,24 @@ h2{margin:0;font-size:1.5rem;font-weight:600}
|
|
100 |
}
|
101 |
button.upload{all:unset;cursor:pointer;border:1px solid #bbb;padding:8px 14px;border-radius:6px;background:#fff;margin:0 8px}
|
102 |
#viewer{
|
103 |
-
width:
|
104 |
-
height:
|
105 |
-
max-width:
|
106 |
margin:0;
|
107 |
background:#fff;
|
108 |
border:1px solid #ddd;
|
109 |
border-radius:8px;
|
110 |
-
position:fixed;
|
111 |
top:50%;
|
112 |
left:50%;
|
113 |
-
transform:translate(-50%, -50%);
|
114 |
-
z-index:1000;
|
115 |
box-shadow:0 4px 20px rgba(0,0,0,0.15);
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
|
118 |
/* FlipBook ์ปจํธ๋กค๋ฐ ๊ด๋ จ ์คํ์ผ ์ค๋ฒ๋ผ์ด๋ */
|
@@ -339,6 +344,42 @@ function createFlipBook(pages) {
|
|
339 |
console.log('FlipBook ์์ฑ ์์. ํ์ด์ง ์:', pages.length);
|
340 |
|
341 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
fb = new FlipBook(viewer, {
|
343 |
pages: pages,
|
344 |
viewMode: 'webgl',
|
@@ -375,6 +416,16 @@ function createFlipBook(pages) {
|
|
375 |
}
|
376 |
});
|
377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
// FlipBook ์์ฑ ํ ์ปจํธ๋กค๋ฐ ๊ฐ์ ํ์
|
379 |
setTimeout(() => {
|
380 |
try {
|
|
|
100 |
}
|
101 |
button.upload{all:unset;cursor:pointer;border:1px solid #bbb;padding:8px 14px;border-radius:6px;background:#fff;margin:0 8px}
|
102 |
#viewer{
|
103 |
+
width:90%;
|
104 |
+
height:90vh;
|
105 |
+
max-width:90%;
|
106 |
margin:0;
|
107 |
background:#fff;
|
108 |
border:1px solid #ddd;
|
109 |
border-radius:8px;
|
110 |
+
position:fixed;
|
111 |
top:50%;
|
112 |
left:50%;
|
113 |
+
transform:translate(-50%, -50%);
|
114 |
+
z-index:1000;
|
115 |
box-shadow:0 4px 20px rgba(0,0,0,0.15);
|
116 |
+
/* ํ๋ฉด ๋น์จ์ ๋ง๊ฒ ์กฐ์ */
|
117 |
+
max-height: calc(90vh - 40px); /* ์ฌ๋ฐฑ ๊ณ ๋ ค */
|
118 |
+
aspect-ratio: auto; /* ๋น์จ ์๋ ์กฐ์ */
|
119 |
+
object-fit: contain; /* ๋ด์ฉ๋ฌผ ๋น์จ ์ ์ง */
|
120 |
+
overflow: hidden; /* ๋ด์ฉ ๋์นจ ๋ฐฉ์ง */
|
121 |
}
|
122 |
|
123 |
/* FlipBook ์ปจํธ๋กค๋ฐ ๊ด๋ จ ์คํ์ผ ์ค๋ฒ๋ผ์ด๋ */
|
|
|
344 |
console.log('FlipBook ์์ฑ ์์. ํ์ด์ง ์:', pages.length);
|
345 |
|
346 |
try {
|
347 |
+
// ํ๋ฉด ๋น์จ ๊ณ์ฐ
|
348 |
+
const calculateAspectRatio = () => {
|
349 |
+
const windowWidth = window.innerWidth;
|
350 |
+
const windowHeight = window.innerHeight;
|
351 |
+
const aspectRatio = windowWidth / windowHeight;
|
352 |
+
|
353 |
+
// ๋๋น ๋๋ ๋์ด ๊ธฐ์ค์ผ๋ก ์ต๋ 90% ์ ํ
|
354 |
+
let width, height;
|
355 |
+
if (aspectRatio > 1) { // ๊ฐ๋ก ํ๋ฉด
|
356 |
+
height = Math.min(windowHeight * 0.9, windowHeight - 40);
|
357 |
+
width = height * aspectRatio * 0.8; // ๊ฐ๋ก ํ๋ฉด์์๋ ์ฝ๊ฐ ์ค์
|
358 |
+
if (width > windowWidth * 0.9) {
|
359 |
+
width = windowWidth * 0.9;
|
360 |
+
height = width / (aspectRatio * 0.8);
|
361 |
+
}
|
362 |
+
} else { // ์ธ๋ก ํ๋ฉด
|
363 |
+
width = Math.min(windowWidth * 0.9, windowWidth - 40);
|
364 |
+
height = width / aspectRatio * 0.9; // ์ธ๋ก ํ๋ฉด์์๋ ์ฝ๊ฐ ๋๋ฆผ
|
365 |
+
if (height > windowHeight * 0.9) {
|
366 |
+
height = windowHeight * 0.9;
|
367 |
+
width = height * aspectRatio * 0.9;
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
// ์ต์ ์ฌ์ด์ฆ ๋ฐํ
|
372 |
+
return {
|
373 |
+
width: Math.round(width),
|
374 |
+
height: Math.round(height)
|
375 |
+
};
|
376 |
+
};
|
377 |
+
|
378 |
+
// ์ด๊ธฐ ํ๋ฉด ๋น์จ ๊ณ์ฐ
|
379 |
+
const size = calculateAspectRatio();
|
380 |
+
viewer.style.width = size.width + 'px';
|
381 |
+
viewer.style.height = size.height + 'px';
|
382 |
+
|
383 |
fb = new FlipBook(viewer, {
|
384 |
pages: pages,
|
385 |
viewMode: 'webgl',
|
|
|
416 |
}
|
417 |
});
|
418 |
|
419 |
+
// ํ๋ฉด ํฌ๊ธฐ ๋ณ๊ฒฝ ์ FlipBook ํฌ๊ธฐ ์กฐ์
|
420 |
+
window.addEventListener('resize', () => {
|
421 |
+
if (fb) {
|
422 |
+
const newSize = calculateAspectRatio();
|
423 |
+
viewer.style.width = newSize.width + 'px';
|
424 |
+
viewer.style.height = newSize.height + 'px';
|
425 |
+
fb.resize();
|
426 |
+
}
|
427 |
+
});
|
428 |
+
|
429 |
// FlipBook ์์ฑ ํ ์ปจํธ๋กค๋ฐ ๊ฐ์ ํ์
|
430 |
setTimeout(() => {
|
431 |
try {
|