rizwarrior commited on
Commit
affdc98
·
1 Parent(s): 65066a0

Implement smooth loading progress animation

Browse files

- Replace hard stop at 90% with exponential decay curve
- Progress smoothly approaches 95% in first 30 seconds, then crawls to 98%
- Update progress every 500ms for smoother visual experience
- Keep percentage display as whole numbers while maintaining smooth bar animation
- Fix Vite proxy port from 5000 to 7860 to match server configuration
- Eliminates 'stuck loading' feeling for better user experience

Files changed (2) hide show
  1. src/App.js +17 -6
  2. vite.config.js +1 -1
src/App.js CHANGED
@@ -22,16 +22,27 @@ function App() {
22
  formData.append('audio', file);
23
 
24
  try {
25
- // Simulate progress updates
 
26
  const progressInterval = setInterval(() => {
27
  setProcessingProgress(prev => {
28
- if (prev >= 90) {
29
- clearInterval(progressInterval);
30
- return prev;
 
 
 
 
 
31
  }
32
- return prev + Math.random() * 10;
 
 
 
 
 
33
  });
34
- }, 1000);
35
 
36
  const response = await fetch('/api/separate', {
37
  method: 'POST',
 
22
  formData.append('audio', file);
23
 
24
  try {
25
+ // Simulate smooth progress updates with exponential decay
26
+ const startTime = Date.now();
27
  const progressInterval = setInterval(() => {
28
  setProcessingProgress(prev => {
29
+ const elapsed = Date.now() - startTime;
30
+ // Use exponential approach to 95% over time, then slow crawl to 98%
31
+ let targetProgress;
32
+ if (elapsed < 30000) { // First 30 seconds: quick progress to 95%
33
+ targetProgress = 95 * (1 - Math.exp(-elapsed / 10000));
34
+ } else { // After 30 seconds: slow crawl from 95% to 98%
35
+ const extraTime = elapsed - 30000;
36
+ targetProgress = 95 + 3 * (1 - Math.exp(-extraTime / 20000));
37
  }
38
+
39
+ // Smooth transition towards target
40
+ const diff = targetProgress - prev;
41
+ const increment = Math.max(0.1, diff * 0.1); // At least 0.1% progress each update
42
+
43
+ return Math.min(98, prev + increment);
44
  });
45
+ }, 500); // Update every 500ms for smoother animation
46
 
47
  const response = await fetch('/api/separate', {
48
  method: 'POST',
vite.config.js CHANGED
@@ -20,7 +20,7 @@ export default defineConfig({
20
  port: 3001,
21
  proxy: {
22
  '/api': {
23
- target: 'http://localhost:5000',
24
  changeOrigin: true,
25
  secure: false,
26
  configure: (proxy, options) => {
 
20
  port: 3001,
21
  proxy: {
22
  '/api': {
23
+ target: 'http://localhost:7860',
24
  changeOrigin: true,
25
  secure: false,
26
  configure: (proxy, options) => {