ginipick commited on
Commit
3de5b8c
·
verified ·
1 Parent(s): 410d91a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +121 -77
index.html CHANGED
@@ -140,42 +140,45 @@
140
  height: 100%;
141
  object-fit: contain;
142
  }
143
- .gallery {
144
- display: grid;
145
- grid-template-columns: repeat(8, 1fr);
146
- gap: 15px;
147
- padding: 20px;
148
- background: linear-gradient(45deg, #1a1a1a, #2c2c2c);
149
- border-radius: 15px;
150
- }
151
- .thumbnail {
152
- position: relative;
153
- padding-top: 56.25%;
154
- cursor: pointer;
155
- overflow: hidden;
156
- background-color: #000;
157
- border: 3px solid #333;
158
- border-radius: 8px;
159
- box-shadow:
160
- 0 5px 15px rgba(0, 0, 0, 0.5),
161
- 0 0 0 1px rgba(255, 255, 255, 0.1);
162
- transition: transform 0.3s ease, box-shadow 0.3s ease;
163
- }
 
 
 
 
 
 
 
 
 
 
 
164
  .thumbnail:hover {
165
  transform: translateY(-5px) scale(1.02);
166
  box-shadow:
167
  0 8px 20px rgba(0, 0, 0, 0.8),
168
  0 0 0 1px rgba(255, 255, 255, 0.2);
169
  }
170
- .thumbnail video {
171
- position: absolute;
172
- top: 0;
173
- left: 0;
174
- width: 100%;
175
- height: 100%;
176
- object-fit: cover;
177
- transition: transform 0.3s ease;
178
- }
179
  .thumbnail:hover video {
180
  transform: scale(1.1);
181
  }
@@ -400,54 +403,95 @@ const videoFiles = [
400
  selectedThumb.currentTime = 0;
401
  }
402
  }
403
- function createVideoElement(thumbnail, videoData, autoload) {
404
- const thumbVideo = document.createElement('video');
405
- thumbVideo.playsinline = true;
406
- thumbVideo.muted = true;
407
- thumbVideo.preload = autoload ? 'metadata' : 'none';
408
- thumbVideo.addEventListener('loadedmetadata', () => {
409
- thumbVideo.currentTime = 0;
410
- });
411
- thumbnail.addEventListener('click', () => {
412
- const selectedThumb = document.getElementById('selected-thumb');
413
- const selectedVideo = document.getElementById('selected-video');
414
-
415
- selectedThumb.src = videoData.file;
416
- selectedVideo.src = videoData.file;
417
- selectedThumb.currentTime = 0;
418
- selectedVideo.play();
419
- });
420
- thumbnail.addEventListener('mouseenter', () => {
421
- if (!thumbVideo.src) {
422
- thumbVideo.src = videoData.file;
423
- }
424
- thumbVideo.play();
425
- });
426
- thumbnail.addEventListener('mouseleave', () => {
427
- thumbVideo.pause();
428
- thumbVideo.currentTime = 0;
429
- });
430
- thumbnail.appendChild(thumbVideo);
431
- }
432
- document.querySelectorAll('.tab-button').forEach(button => {
433
- button.addEventListener('click', () => {
434
- document.querySelectorAll('.tab-button').forEach(btn =>
435
- btn.classList.remove('active'));
436
- button.classList.add('active');
437
- showTabContent(button.dataset.tab);
438
- });
439
- });
440
- function showTabContent(tabNumber) {
441
- const thumbnails = document.querySelectorAll('.thumbnail');
442
- thumbnails.forEach(thumb => {
443
- if (thumb.dataset.tab === tabNumber) {
444
- thumb.style.display = 'block';
445
- } else {
446
- thumb.style.display = 'none';
447
- }
448
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  }
450
- initializeGallery();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  </script>
452
  </body>
453
  </html>
 
140
  height: 100%;
141
  object-fit: contain;
142
  }
143
+
144
+
145
+ .thumbnail {
146
+ position: relative;
147
+ padding-top: 56.25%;
148
+ cursor: pointer;
149
+ overflow: hidden;
150
+ background-color: #000;
151
+ border: 3px solid #333;
152
+ border-radius: 8px;
153
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
154
+ transition: transform 0.3s ease;
155
+ }
156
+
157
+ .thumbnail video {
158
+ position: absolute;
159
+ top: 0;
160
+ left: 0;
161
+ width: 100%;
162
+ height: 100%;
163
+ object-fit: cover;
164
+ }
165
+
166
+ .gallery {
167
+ display: grid;
168
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
169
+ gap: 15px;
170
+ padding: 20px;
171
+ background: linear-gradient(45deg, #1a1a1a, #2c2c2c);
172
+ border-radius: 15px;
173
+ }
174
+
175
  .thumbnail:hover {
176
  transform: translateY(-5px) scale(1.02);
177
  box-shadow:
178
  0 8px 20px rgba(0, 0, 0, 0.8),
179
  0 0 0 1px rgba(255, 255, 255, 0.2);
180
  }
181
+
 
 
 
 
 
 
 
 
182
  .thumbnail:hover video {
183
  transform: scale(1.1);
184
  }
 
403
  selectedThumb.currentTime = 0;
404
  }
405
  }
406
+ function createVideoElement(thumbnail, videoData, autoload) {
407
+ const thumbVideo = document.createElement('video');
408
+ thumbVideo.src = videoData.file; // 직접 src 설정
409
+ thumbVideo.playsinline = true;
410
+ thumbVideo.muted = true;
411
+ thumbVideo.loop = true; // 반복 재생 추가
412
+ thumbVideo.preload = 'metadata';
413
+
414
+ // 비디오 로드 완료 후 처리
415
+ thumbVideo.addEventListener('loadeddata', () => {
416
+ thumbVideo.currentTime = 0;
417
+ });
418
+
419
+ // 에러 처리 추가
420
+ thumbVideo.addEventListener('error', (e) => {
421
+ console.error('Video loading error:', e);
422
+ thumbnail.style.backgroundColor = '#333';
423
+ });
424
+
425
+ thumbnail.addEventListener('mouseenter', () => {
426
+ thumbVideo.play().catch(e => console.log('Playback failed:', e));
427
+ });
428
+
429
+ thumbnail.addEventListener('mouseleave', () => {
430
+ thumbVideo.pause();
431
+ thumbVideo.currentTime = 0;
432
+ });
433
+
434
+ thumbnail.addEventListener('click', () => {
435
+ const selectedThumb = document.getElementById('selected-thumb');
436
+ const selectedVideo = document.getElementById('selected-video');
437
+
438
+ selectedThumb.src = videoData.file;
439
+ selectedVideo.src = videoData.file;
440
+ selectedVideo.play().catch(e => console.log('Playback failed:', e));
441
+ });
442
+
443
+ thumbnail.appendChild(thumbVideo);
444
+ }
445
+
446
+ function initializeGallery() {
447
+ const gallery = document.getElementById('video-gallery');
448
+ const selectedThumb = document.getElementById('selected-thumb');
449
+ const selectedVideo = document.getElementById('selected-video');
450
+
451
+ // 초기 비디오 설정
452
+ if (videoFiles.length > 0) {
453
+ selectedThumb.src = videoFiles[0].file;
454
+ selectedVideo.src = videoFiles[0].file;
455
+ }
456
+
457
+ // 모든 비디오 썸네일 생성
458
+ videoFiles.forEach((videoData) => {
459
+ const thumbnail = document.createElement('div');
460
+ thumbnail.className = 'thumbnail';
461
+ thumbnail.dataset.tab = videoData.tab;
462
+
463
+ createVideoElement(thumbnail, videoData, true);
464
+ gallery.appendChild(thumbnail);
465
+ });
466
+
467
+ // 첫 번째 탭 컨텐츠 표시
468
+ showTabContent('1');
469
+ }
470
+
471
+ // 탭 컨텐츠 표시 함수
472
+ function showTabContent(tabNumber) {
473
+ const thumbnails = document.querySelectorAll('.thumbnail');
474
+ thumbnails.forEach(thumb => {
475
+ if (thumb.dataset.tab === tabNumber) {
476
+ thumb.style.display = 'block';
477
+ } else {
478
+ thumb.style.display = 'none';
479
  }
480
+ });
481
+ }
482
+
483
+ // 탭 버튼 이벤트 리스너
484
+ document.querySelectorAll('.tab-button').forEach(button => {
485
+ button.addEventListener('click', () => {
486
+ document.querySelectorAll('.tab-button').forEach(btn =>
487
+ btn.classList.remove('active'));
488
+ button.classList.add('active');
489
+ showTabContent(button.dataset.tab);
490
+ });
491
+ });
492
+
493
+ // 갤러리 초기화
494
+ initializeGallery();
495
  </script>
496
  </body>
497
  </html>