yangdx
commited on
Commit
·
ef28336
1
Parent(s):
5738870
Simplify zoom control logic by using fixed ratio
Browse files
lightrag/api/webui/assets/{index-BNaZrUgP.js → index-DG6MIDBJ.js}
RENAMED
Binary files a/lightrag/api/webui/assets/index-BNaZrUgP.js and b/lightrag/api/webui/assets/index-DG6MIDBJ.js differ
|
|
lightrag/api/webui/index.html
CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
|
|
lightrag_webui/src/components/graph/ZoomControl.tsx
CHANGED
@@ -46,37 +46,8 @@ const ZoomControl = () => {
|
|
46 |
return
|
47 |
}
|
48 |
|
49 |
-
// Get all node positions
|
50 |
-
const nodePositions = graph.nodes().map(node => ({
|
51 |
-
x: graph.getNodeAttribute(node, 'x'),
|
52 |
-
y: graph.getNodeAttribute(node, 'y')
|
53 |
-
}))
|
54 |
-
|
55 |
-
// Calculate bounding box
|
56 |
-
const minX = Math.min(...nodePositions.map(pos => pos.x))
|
57 |
-
const maxX = Math.max(...nodePositions.map(pos => pos.x))
|
58 |
-
const minY = Math.min(...nodePositions.map(pos => pos.y))
|
59 |
-
const maxY = Math.max(...nodePositions.map(pos => pos.y))
|
60 |
-
|
61 |
-
// Calculate graph dimensions with minimal padding
|
62 |
-
const width = maxX - minX
|
63 |
-
const height = maxY - minY
|
64 |
-
// const padding = Math.max(width, height) * 0.05
|
65 |
-
console.log('Graph W:', Math.round(width*100)/100, 'H:', Math.round(height*100)/100)
|
66 |
-
|
67 |
-
// Calculate base scale
|
68 |
-
const scale = Math.min(
|
69 |
-
(containerWidth - containerPadding * 2) / width,
|
70 |
-
(containerHeight - containerPadding * 2) / height
|
71 |
-
)
|
72 |
-
// Apply scaling factor (just don't know why)
|
73 |
-
const ratio = (1 / scale) * 10
|
74 |
-
|
75 |
-
console.log('scale:', Math.round(scale*100)/100, 'ratio:', Math.round(ratio*100)/100)
|
76 |
-
|
77 |
-
// Animate to center with calculated ratio
|
78 |
sigma.getCamera().animate(
|
79 |
-
{ x: 0.5, y: 0.5, ratio },
|
80 |
{ duration: 1000 }
|
81 |
)
|
82 |
} catch (error) {
|
|
|
46 |
return
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
sigma.getCamera().animate(
|
50 |
+
{ x: 0.5, y: 0.5, ratio: 1.1 },
|
51 |
{ duration: 1000 }
|
52 |
)
|
53 |
} catch (error) {
|