yangdx commited on
Commit
ab63413
·
1 Parent(s): 4093704

Optimized graph layout animation parameters, Smoothed overlapping animations

Browse files

- Reduced animation duration to 300ms
- Decreased update interval to 200ms
- Extended auto-stop timeout to 3 seconds

lightrag_webui/src/components/graph/LayoutsControl.tsx CHANGED
@@ -53,7 +53,7 @@ const WorkerLayoutControl = ({ layout, autoRunFor, mainLayout }: ExtendedWorkerL
53
 
54
  // Animate nodes to new positions
55
  // console.log('Updating node positions with layout algorithm')
56
- animateNodes(graph, positions, { duration: 400 }) // Increase duration for smoother transitions
57
  } catch (error) {
58
  console.error('Error updating positions:', error)
59
  // Stop animation if there's an error
@@ -99,14 +99,14 @@ const WorkerLayoutControl = ({ layout, autoRunFor, mainLayout }: ExtendedWorkerL
99
  // Set up interval for continuous updates
100
  animationTimerRef.current = window.setInterval(() => {
101
  updatePositions()
102
- }, 400) // Match interval with animation duration for smoother transitions
103
 
104
  setIsRunning(true)
105
 
106
- // Set a timeout to automatically stop the animation after 2 seconds
107
  setTimeout(() => {
108
  if (animationTimerRef.current) {
109
- console.log('Auto-stopping layout animation after 2 seconds')
110
  window.clearInterval(animationTimerRef.current)
111
  animationTimerRef.current = null
112
  setIsRunning(false)
@@ -122,7 +122,7 @@ const WorkerLayoutControl = ({ layout, autoRunFor, mainLayout }: ExtendedWorkerL
122
  console.error('Error stopping layout algorithm:', error)
123
  }
124
  }
125
- }, 2000)
126
  }
127
  }, [isRunning, layout, updatePositions])
128
 
@@ -146,7 +146,7 @@ const WorkerLayoutControl = ({ layout, autoRunFor, mainLayout }: ExtendedWorkerL
146
  // Set up interval for continuous updates
147
  animationTimerRef.current = window.setInterval(() => {
148
  updatePositions()
149
- }, 400) // Match interval with animation duration for smoother transitions
150
 
151
  setIsRunning(true)
152
 
@@ -270,7 +270,7 @@ const LayoutsControl = () => {
270
 
271
  const pos = positions()
272
  console.log('Positions calculated, animating nodes')
273
- animateNodes(graph, pos, { duration: 500 })
274
  setLayout(newLayout)
275
  } catch (error) {
276
  console.error('Error running layout:', error)
 
53
 
54
  // Animate nodes to new positions
55
  // console.log('Updating node positions with layout algorithm')
56
+ animateNodes(graph, positions, { duration: 300 }) // Reduced duration for more frequent updates
57
  } catch (error) {
58
  console.error('Error updating positions:', error)
59
  // Stop animation if there's an error
 
99
  // Set up interval for continuous updates
100
  animationTimerRef.current = window.setInterval(() => {
101
  updatePositions()
102
+ }, 200) // Reduced interval to create overlapping animations for smoother transitions
103
 
104
  setIsRunning(true)
105
 
106
+ // Set a timeout to automatically stop the animation after 3 seconds
107
  setTimeout(() => {
108
  if (animationTimerRef.current) {
109
+ console.log('Auto-stopping layout animation after 3 seconds')
110
  window.clearInterval(animationTimerRef.current)
111
  animationTimerRef.current = null
112
  setIsRunning(false)
 
122
  console.error('Error stopping layout algorithm:', error)
123
  }
124
  }
125
+ }, 3000)
126
  }
127
  }, [isRunning, layout, updatePositions])
128
 
 
146
  // Set up interval for continuous updates
147
  animationTimerRef.current = window.setInterval(() => {
148
  updatePositions()
149
+ }, 200) // Reduced interval to create overlapping animations for smoother transitions
150
 
151
  setIsRunning(true)
152
 
 
270
 
271
  const pos = positions()
272
  console.log('Positions calculated, animating nodes')
273
+ animateNodes(graph, pos, { duration: 400 })
274
  setLayout(newLayout)
275
  } catch (error) {
276
  console.error('Error running layout:', error)