ginipick commited on
Commit
ed6dfe5
ยท
verified ยท
1 Parent(s): 9e3d558

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -6
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:88%;
104
- height:88vh; /* ์ „์ฒด ํ™”๋ฉด ๋†’์ด์˜ 88%๋กœ ์กฐ์ • (๊ธฐ์กด 80%์—์„œ 10% ์ฆ๊ฐ€) */
105
- max-width:88%; /* ์ตœ๋Œ€ ๋„ˆ๋น„ 88%๋กœ ์ œํ•œ (๊ธฐ์กด 80%์—์„œ 10% ์ฆ๊ฐ€) */
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 {