@andespindola/brainlink 0.1.0-beta.25 → 0.1.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -156,14 +156,14 @@ const graphBounds = nodes => {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const fitScaleBiasByNodeCount = nodeCount => {
|
|
159
|
-
if (nodeCount <= 6) return 2.
|
|
160
|
-
if (nodeCount <= 20) return
|
|
161
|
-
if (nodeCount <= 60) return 1.
|
|
162
|
-
if (nodeCount <= 180) return 1.
|
|
163
|
-
if (nodeCount <= 600) return 1.
|
|
159
|
+
if (nodeCount <= 6) return 2.8
|
|
160
|
+
if (nodeCount <= 20) return 2.2
|
|
161
|
+
if (nodeCount <= 60) return 1.72
|
|
162
|
+
if (nodeCount <= 180) return 1.34
|
|
163
|
+
if (nodeCount <= 600) return 1.08
|
|
164
164
|
if (nodeCount <= 2000) return 0.9
|
|
165
165
|
if (nodeCount <= 6000) return 0.72
|
|
166
|
-
return 0.
|
|
166
|
+
return 0.58
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
const fitView = (options = { useFiltered: true }) => {
|
|
@@ -178,13 +178,34 @@ const fitView = (options = { useFiltered: true }) => {
|
|
|
178
178
|
return
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
const
|
|
181
|
+
const paddingByNodeCount = nodeCount => {
|
|
182
|
+
if (nodeCount <= 6) return 28
|
|
183
|
+
if (nodeCount <= 20) return 44
|
|
184
|
+
if (nodeCount <= 60) return 68
|
|
185
|
+
if (nodeCount <= 180) return 86
|
|
186
|
+
if (nodeCount <= 600) return 110
|
|
187
|
+
if (nodeCount <= 2000) return 140
|
|
188
|
+
return 180
|
|
189
|
+
}
|
|
190
|
+
const minFitScaleByNodeCount = nodeCount => {
|
|
191
|
+
if (nodeCount <= 6) return 2.4
|
|
192
|
+
if (nodeCount <= 20) return 1.8
|
|
193
|
+
if (nodeCount <= 60) return 1.2
|
|
194
|
+
if (nodeCount <= 180) return 0.86
|
|
195
|
+
if (nodeCount <= 600) return 0.58
|
|
196
|
+
if (nodeCount <= 2000) return 0.34
|
|
197
|
+
if (nodeCount <= 6000) return 0.2
|
|
198
|
+
return 0.13
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const padding = paddingByNodeCount(nodes.length)
|
|
182
202
|
const scaleX = width / (bounds.width + padding * 2)
|
|
183
203
|
const scaleY = height / (bounds.height + padding * 2)
|
|
184
204
|
const fitScale = clampScale(Math.min(scaleX, scaleY))
|
|
185
205
|
const biasedScale = clampScale(fitScale * fitScaleBiasByNodeCount(nodes.length))
|
|
206
|
+
const minimumScale = minFitScaleByNodeCount(nodes.length)
|
|
186
207
|
const minimumLargeGraphScale = nodes.length > largeGraphNodeThreshold ? 0.13 : zoomRange.min
|
|
187
|
-
const scale = Math.max(biasedScale, minimumLargeGraphScale)
|
|
208
|
+
const scale = Math.max(biasedScale, minimumScale, minimumLargeGraphScale)
|
|
188
209
|
const centerX = (bounds.minX + bounds.maxX) / 2
|
|
189
210
|
const centerY = (bounds.minY + bounds.maxY) / 2
|
|
190
211
|
|
|
@@ -653,16 +674,17 @@ const zoomAtPoint = (screenX, screenY, factor) => {
|
|
|
653
674
|
|
|
654
675
|
const wheelZoomFactor = event => {
|
|
655
676
|
const isModifierZoom = event.metaKey || event.ctrlKey
|
|
656
|
-
const
|
|
677
|
+
const deltaModeFactor = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? 120 : 1
|
|
678
|
+
const normalizedDelta = Math.min(Math.abs(event.deltaY * deltaModeFactor), 1200) / 220
|
|
657
679
|
|
|
658
|
-
if (
|
|
659
|
-
return
|
|
680
|
+
if (normalizedDelta <= 0.0001) {
|
|
681
|
+
return 1
|
|
660
682
|
}
|
|
661
683
|
|
|
662
|
-
const
|
|
663
|
-
const
|
|
684
|
+
const sensitivity = isModifierZoom ? 0.2 : 0.14
|
|
685
|
+
const direction = event.deltaY < 0 ? 1 : -1
|
|
664
686
|
|
|
665
|
-
return
|
|
687
|
+
return Math.exp(direction * normalizedDelta * sensitivity)
|
|
666
688
|
}
|
|
667
689
|
|
|
668
690
|
const bindEvents = () => {
|
|
@@ -749,6 +771,9 @@ const bindEvents = () => {
|
|
|
749
771
|
state.pointer = { x: 0, y: 0, down: false, dragNode: null, moved: false }
|
|
750
772
|
canvas.releasePointerCapture(event.pointerId)
|
|
751
773
|
})
|
|
774
|
+
canvas.addEventListener('pointercancel', () => {
|
|
775
|
+
state.pointer = { x: 0, y: 0, down: false, dragNode: null, moved: false }
|
|
776
|
+
})
|
|
752
777
|
}
|
|
753
778
|
|
|
754
779
|
const loadAgents = async () => {
|
package/package.json
CHANGED