SeaWolf-AI commited on
Commit
6cc1497
·
verified ·
1 Parent(s): 6c4238a

Smooth 15s progress bar — 0->95% linear over 15s, snap 100% on sigma render

Browse files
Files changed (1) hide show
  1. index.html +41 -20
index.html CHANGED
@@ -37,43 +37,64 @@
37
  </div>
38
  </div>
39
  <script>
40
- // Hide overlay once sigma is initialized + show progress on data fetch
 
41
  (function(){
42
  var s = document.getElementById('loading-status');
43
  var bar = document.getElementById('loading-bar');
44
  var overlay = document.getElementById('loading-overlay');
45
- var origFetch = window.fetch;
46
- var step = 0;
 
 
 
 
47
  var stages = [
48
- 'Atlas 메타데이터 로드 중…',
49
- '압축된 그래프 다운로드 중…',
50
- 'Gzip 압축 해제 중…',
51
- '노드 / 엣지 파싱 중…',
52
- 'Sigma.js 레이아웃 계산 중…',
53
- '거의 완료…'
54
  ];
55
- var i = 0;
 
 
 
 
 
56
  var tick = setInterval(function(){
57
- if (i < stages.length) { s.textContent = stages[i]; bar.style.width = ((i+1)*16) + '%'; i++; }
58
- }, 1200);
59
- // Watchdog: hide overlay when canvas has children (sigma rendered)
 
 
 
 
 
60
  var watch = setInterval(function(){
61
  var canvas = document.querySelectorAll('#sigma-canvas canvas');
62
  if (canvas.length > 0) {
 
63
  clearInterval(watch); clearInterval(tick);
64
- bar.style.width = '100%'; s.textContent = '완료 ✓';
 
65
  setTimeout(function(){
66
  overlay.style.opacity = '0';
67
- setTimeout(function(){ overlay.style.display = 'none'; }, 400);
68
- }, 250);
69
  }
70
- }, 250);
71
- // Hard cap: hide after 30s no matter what
 
72
  setTimeout(function(){
73
  if (overlay.style.display !== 'none') {
74
- overlay.style.opacity = '0';
75
- setTimeout(function(){ overlay.style.display = 'none'; }, 400);
76
  clearInterval(watch); clearInterval(tick);
 
 
 
 
77
  }
78
  }, 30000);
79
  })();
 
37
  </div>
38
  </div>
39
  <script>
40
+ // Smooth 15-second progress fill (0% -> 95%) with rotating Korean stage labels.
41
+ // Snaps to 100% and fades out when sigma renders the canvas.
42
  (function(){
43
  var s = document.getElementById('loading-status');
44
  var bar = document.getElementById('loading-bar');
45
  var overlay = document.getElementById('loading-overlay');
46
+ var TARGET_MS = 15000; // fill to 95% over 15s
47
+ var TICK_MS = 100; // smooth update every 100ms
48
+ var FINAL_PCT = 95; // hold at 95% if canvas not yet ready
49
+ var start = Date.now();
50
+ var done = false;
51
+
52
  var stages = [
53
+ [0, 'Atlas 메타데이터 로드 중…'],
54
+ [2200, '압축된 그래프 다운로드 중… (3 MB gzip)'],
55
+ [4800, 'Gzip 압축 해제 중… (≈ 27 MB JSON)'],
56
+ [7800, '노드 22,482개 파싱 중…'],
57
+ [10800, 'Sigma.js 레이아웃 계산 중…'],
58
+ [13200, 'Canvas 렌더링 중…'],
59
  ];
60
+ function updateStage(elapsed){
61
+ for (var k = stages.length - 1; k >= 0; k--){
62
+ if (elapsed >= stages[k][0]) { s.textContent = stages[k][1]; return; }
63
+ }
64
+ }
65
+
66
  var tick = setInterval(function(){
67
+ if (done) return;
68
+ var elapsed = Date.now() - start;
69
+ var pct = Math.min(FINAL_PCT, (elapsed / TARGET_MS) * FINAL_PCT);
70
+ bar.style.width = pct.toFixed(1) + '%';
71
+ updateStage(elapsed);
72
+ }, TICK_MS);
73
+
74
+ // Watchdog: when sigma canvas exists, snap to 100% and fade
75
  var watch = setInterval(function(){
76
  var canvas = document.querySelectorAll('#sigma-canvas canvas');
77
  if (canvas.length > 0) {
78
+ done = true;
79
  clearInterval(watch); clearInterval(tick);
80
+ bar.style.width = '100%';
81
+ s.textContent = '완료 ✓';
82
  setTimeout(function(){
83
  overlay.style.opacity = '0';
84
+ setTimeout(function(){ overlay.style.display = 'none'; }, 500);
85
+ }, 350);
86
  }
87
+ }, 200);
88
+
89
+ // Hard cap at 30s — force-hide regardless
90
  setTimeout(function(){
91
  if (overlay.style.display !== 'none') {
92
+ done = true;
 
93
  clearInterval(watch); clearInterval(tick);
94
+ bar.style.width = '100%';
95
+ s.textContent = '완료 ✓';
96
+ overlay.style.opacity = '0';
97
+ setTimeout(function(){ overlay.style.display = 'none'; }, 500);
98
  }
99
  }, 30000);
100
  })();