@antv/g6 5.0.0-beta.2 → 5.0.0-beta.20

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.
Files changed (608) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/api-doc/types.d.ts +1 -0
  6. package/esm/api-doc/types.js +1 -2
  7. package/esm/api-doc/types.js.map +1 -1
  8. package/esm/constant/shape.d.ts +3 -1
  9. package/esm/index.d.ts +24 -63
  10. package/esm/index.js +4 -5
  11. package/esm/index.js.map +1 -1
  12. package/esm/item/combo.d.ts +1 -1
  13. package/esm/item/combo.js +18 -14
  14. package/esm/item/combo.js.map +1 -1
  15. package/esm/item/edge.d.ts +19 -2
  16. package/esm/item/edge.js +100 -44
  17. package/esm/item/edge.js.map +1 -1
  18. package/esm/item/item.d.ts +3 -2
  19. package/esm/item/item.js +27 -13
  20. package/esm/item/item.js.map +1 -1
  21. package/esm/item/node.d.ts +2 -8
  22. package/esm/item/node.js +31 -19
  23. package/esm/item/node.js.map +1 -1
  24. package/esm/runtime/controller/data.d.ts +7 -10
  25. package/esm/runtime/controller/data.js +125 -281
  26. package/esm/runtime/controller/data.js.map +1 -1
  27. package/esm/runtime/controller/interaction.js +9 -4
  28. package/esm/runtime/controller/interaction.js.map +1 -1
  29. package/esm/runtime/controller/item.d.ts +1 -0
  30. package/esm/runtime/controller/item.js +285 -150
  31. package/esm/runtime/controller/item.js.map +1 -1
  32. package/esm/runtime/controller/layout.js +1 -3
  33. package/esm/runtime/controller/layout.js.map +1 -1
  34. package/esm/runtime/controller/plugin.js +9 -5
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/graph.d.ts +104 -24
  37. package/esm/runtime/graph.js +472 -94
  38. package/esm/runtime/graph.js.map +1 -1
  39. package/esm/stdlib/behavior/activate-relations.d.ts +1 -1
  40. package/esm/stdlib/behavior/activate-relations.js +2 -2
  41. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  42. package/esm/stdlib/behavior/brush-select.d.ts +9 -3
  43. package/esm/stdlib/behavior/brush-select.js +10 -12
  44. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  45. package/esm/stdlib/behavior/click-select.d.ts +1 -1
  46. package/esm/stdlib/behavior/click-select.js +1 -1
  47. package/esm/stdlib/behavior/click-select.js.map +1 -1
  48. package/esm/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  49. package/esm/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  50. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  51. package/esm/stdlib/behavior/create-edge.js +215 -0
  52. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  53. package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
  54. package/esm/stdlib/behavior/drag-canvas.js +78 -33
  55. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  56. package/esm/stdlib/behavior/drag-combo.d.ts +3 -3
  57. package/esm/stdlib/behavior/drag-combo.js +43 -32
  58. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  59. package/esm/stdlib/behavior/drag-node.d.ts +4 -4
  60. package/esm/stdlib/behavior/drag-node.js +80 -63
  61. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  62. package/esm/stdlib/behavior/index.d.ts +3 -0
  63. package/esm/stdlib/behavior/index.js +3 -0
  64. package/esm/stdlib/behavior/index.js.map +1 -1
  65. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  66. package/esm/stdlib/behavior/lasso-select.js +3 -4
  67. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  68. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  69. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  70. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  71. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  72. package/esm/stdlib/behavior/shortcuts-call.js +87 -0
  73. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  74. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  75. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  76. package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
  77. package/esm/stdlib/behavior/zoom-canvas.js +70 -26
  78. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  79. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  80. package/esm/stdlib/data/mapNodeSize.js +2 -2
  81. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  82. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  83. package/esm/stdlib/data/transformV4Data.js +2 -2
  84. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  85. package/esm/stdlib/data/validateData.d.ts +2 -2
  86. package/esm/stdlib/data/validateData.js +13 -12
  87. package/esm/stdlib/data/validateData.js.map +1 -1
  88. package/esm/stdlib/index.d.ts +18 -6
  89. package/esm/stdlib/index.js +22 -10
  90. package/esm/stdlib/index.js.map +1 -1
  91. package/esm/stdlib/item/edge/base.d.ts +3 -5
  92. package/esm/stdlib/item/edge/base.js +32 -31
  93. package/esm/stdlib/item/edge/base.js.map +1 -1
  94. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  95. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  96. package/esm/stdlib/item/edge/cubic.js +1 -1
  97. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  98. package/esm/stdlib/item/edge/loop.js +1 -1
  99. package/esm/stdlib/item/edge/loop.js.map +1 -1
  100. package/esm/stdlib/item/node/base.d.ts +3 -6
  101. package/esm/stdlib/item/node/base.js +30 -60
  102. package/esm/stdlib/item/node/base.js.map +1 -1
  103. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  104. package/esm/stdlib/item/node/base3d.js +1 -0
  105. package/esm/stdlib/item/node/base3d.js.map +1 -1
  106. package/esm/stdlib/item/node/cube.d.ts +35 -0
  107. package/esm/stdlib/item/node/cube.js +54 -0
  108. package/esm/stdlib/item/node/cube.js.map +1 -0
  109. package/esm/stdlib/item/node/diamond.js +1 -1
  110. package/esm/stdlib/item/node/donut.d.ts +3 -3
  111. package/esm/stdlib/item/node/ellipse.js +2 -2
  112. package/esm/stdlib/item/node/hexagon.js +6 -2
  113. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  114. package/esm/stdlib/item/node/image.d.ts +40 -0
  115. package/esm/stdlib/item/node/image.js +110 -0
  116. package/esm/stdlib/item/node/image.js.map +1 -0
  117. package/esm/stdlib/item/node/index.d.ts +4 -0
  118. package/esm/stdlib/item/node/index.js +4 -0
  119. package/esm/stdlib/item/node/index.js.map +1 -1
  120. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  121. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  122. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  123. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  124. package/esm/stdlib/plugin/grid/index.js +3 -4
  125. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  126. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  127. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  128. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  129. package/esm/stdlib/plugin/history/index.js +14 -14
  130. package/esm/stdlib/plugin/history/index.js.map +1 -1
  131. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  132. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  133. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  134. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  135. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  136. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  137. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  138. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  139. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  140. package/esm/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  141. package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
  142. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  143. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  144. package/esm/stdlib/plugin/hull/util.js +6 -2
  145. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  146. package/esm/stdlib/plugin/index.d.ts +2 -0
  147. package/esm/stdlib/plugin/index.js +2 -0
  148. package/esm/stdlib/plugin/index.js.map +1 -1
  149. package/esm/stdlib/plugin/legend/index.d.ts +3 -3
  150. package/esm/stdlib/plugin/legend/index.js +3 -3
  151. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  152. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  153. package/esm/stdlib/plugin/menu/index.js +3 -3
  154. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  155. package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
  156. package/esm/stdlib/plugin/minimap/index.js +119 -12
  157. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  158. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  159. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  160. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  161. package/esm/stdlib/plugin/timebar/index.d.ts +4 -4
  162. package/esm/stdlib/plugin/timebar/index.js +6 -6
  163. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  165. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  166. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  167. package/esm/stdlib/plugin/tooltip/index.d.ts +5 -5
  168. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  169. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  170. package/esm/stdlib/plugin/types.d.ts +2 -0
  171. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  172. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  173. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  174. package/esm/stdlib/theme/dark.js +42 -2
  175. package/esm/stdlib/theme/dark.js.map +1 -1
  176. package/esm/stdlib/theme/light.js +4 -4
  177. package/esm/types/animate.d.ts +2 -2
  178. package/esm/types/behavior.d.ts +1 -1
  179. package/esm/types/combo.d.ts +7 -7
  180. package/esm/types/common.d.ts +5 -5
  181. package/esm/types/data.d.ts +6 -6
  182. package/esm/types/edge.d.ts +9 -9
  183. package/esm/types/event.d.ts +2 -1
  184. package/esm/types/graph.d.ts +48 -22
  185. package/esm/types/history.d.ts +2 -2
  186. package/esm/types/hook.d.ts +23 -3
  187. package/esm/types/index.d.ts +2 -1
  188. package/esm/types/index.js +1 -0
  189. package/esm/types/index.js.map +1 -1
  190. package/esm/types/item.d.ts +18 -12
  191. package/esm/types/item.js.map +1 -1
  192. package/esm/types/layout.d.ts +6 -6
  193. package/esm/types/loop.d.ts +2 -2
  194. package/esm/types/node.d.ts +7 -7
  195. package/esm/types/plugin.d.ts +1 -1
  196. package/esm/types/render.d.ts +1 -1
  197. package/esm/types/spec.d.ts +19 -3
  198. package/esm/types/stdlib.d.ts +1 -1
  199. package/esm/types/theme.d.ts +8 -8
  200. package/esm/types/view.d.ts +7 -2
  201. package/esm/util/bbox.d.ts +16 -1
  202. package/esm/util/bbox.js +33 -5
  203. package/esm/util/bbox.js.map +1 -1
  204. package/esm/util/behavior.d.ts +2 -2
  205. package/esm/util/behavior.js +2 -2
  206. package/esm/util/behavior.js.map +1 -1
  207. package/esm/util/data.d.ts +2 -2
  208. package/esm/util/data.js.map +1 -1
  209. package/esm/util/dom.d.ts +15 -0
  210. package/esm/util/dom.js +29 -0
  211. package/esm/util/dom.js.map +1 -0
  212. package/esm/util/event.d.ts +5 -3
  213. package/esm/util/event.js +8 -1
  214. package/esm/util/event.js.map +1 -1
  215. package/esm/util/extend.d.ts +1 -1
  216. package/esm/util/extend.js +0 -1
  217. package/esm/util/extend.js.map +1 -1
  218. package/esm/util/index.d.ts +7 -52
  219. package/esm/util/index.js +7 -23
  220. package/esm/util/index.js.map +1 -1
  221. package/esm/util/item.d.ts +16 -1
  222. package/esm/util/item.js +31 -8
  223. package/esm/util/item.js.map +1 -1
  224. package/esm/util/layout.d.ts +13 -2
  225. package/esm/util/layout.js +45 -0
  226. package/esm/util/layout.js.map +1 -1
  227. package/esm/util/loop.d.ts +1 -1
  228. package/esm/util/loop.js +4 -0
  229. package/esm/util/loop.js.map +1 -1
  230. package/esm/util/math.d.ts +1 -1
  231. package/esm/util/matrix.d.ts +6 -0
  232. package/esm/util/matrix.js +48 -0
  233. package/esm/util/matrix.js.map +1 -0
  234. package/esm/util/path.js +1 -1
  235. package/esm/util/path.js.map +1 -1
  236. package/esm/util/point.d.ts +1 -1
  237. package/esm/util/point.js +9 -2
  238. package/esm/util/point.js.map +1 -1
  239. package/esm/util/polyline.d.ts +2 -1
  240. package/esm/util/polyline.js +2 -1
  241. package/esm/util/polyline.js.map +1 -1
  242. package/esm/util/router.d.ts +1 -1
  243. package/esm/util/shape.d.ts +1 -2
  244. package/esm/util/shape.js +15 -25
  245. package/esm/util/shape.js.map +1 -1
  246. package/esm/util/shape3d.js +16 -17
  247. package/esm/util/shape3d.js.map +1 -1
  248. package/esm/util/text.d.ts +1 -1
  249. package/esm/util/text.js +3 -2
  250. package/esm/util/text.js.map +1 -1
  251. package/esm/util/warn.d.ts +14 -0
  252. package/esm/util/warn.js +4 -0
  253. package/esm/util/warn.js.map +1 -0
  254. package/lib/api-doc/graph.d.ts +3 -3
  255. package/lib/api-doc/graph.js +27 -7
  256. package/lib/api-doc/graph.js.map +1 -1
  257. package/lib/api-doc/types.d.ts +1 -0
  258. package/lib/api-doc/types.js +2 -2
  259. package/lib/api-doc/types.js.map +1 -1
  260. package/lib/constant/shape.d.ts +3 -1
  261. package/lib/index.d.ts +24 -63
  262. package/lib/index.js +18 -10
  263. package/lib/index.js.map +1 -1
  264. package/lib/item/combo.d.ts +1 -1
  265. package/lib/item/combo.js +18 -14
  266. package/lib/item/combo.js.map +1 -1
  267. package/lib/item/edge.d.ts +19 -2
  268. package/lib/item/edge.js +99 -43
  269. package/lib/item/edge.js.map +1 -1
  270. package/lib/item/item.d.ts +3 -2
  271. package/lib/item/item.js +27 -13
  272. package/lib/item/item.js.map +1 -1
  273. package/lib/item/node.d.ts +2 -8
  274. package/lib/item/node.js +31 -19
  275. package/lib/item/node.js.map +1 -1
  276. package/lib/runtime/controller/data.d.ts +7 -10
  277. package/lib/runtime/controller/data.js +125 -281
  278. package/lib/runtime/controller/data.js.map +1 -1
  279. package/lib/runtime/controller/interaction.js +9 -4
  280. package/lib/runtime/controller/interaction.js.map +1 -1
  281. package/lib/runtime/controller/item.d.ts +1 -0
  282. package/lib/runtime/controller/item.js +284 -149
  283. package/lib/runtime/controller/item.js.map +1 -1
  284. package/lib/runtime/controller/layout.js +1 -3
  285. package/lib/runtime/controller/layout.js.map +1 -1
  286. package/lib/runtime/controller/plugin.js +9 -5
  287. package/lib/runtime/controller/plugin.js.map +1 -1
  288. package/lib/runtime/graph.d.ts +104 -24
  289. package/lib/runtime/graph.js +473 -94
  290. package/lib/runtime/graph.js.map +1 -1
  291. package/lib/stdlib/behavior/activate-relations.d.ts +1 -1
  292. package/lib/stdlib/behavior/activate-relations.js +2 -2
  293. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  294. package/lib/stdlib/behavior/brush-select.d.ts +9 -3
  295. package/lib/stdlib/behavior/brush-select.js +13 -12
  296. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  297. package/lib/stdlib/behavior/click-select.d.ts +1 -1
  298. package/lib/stdlib/behavior/click-select.js +1 -1
  299. package/lib/stdlib/behavior/click-select.js.map +1 -1
  300. package/lib/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  301. package/lib/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  302. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  303. package/lib/stdlib/behavior/create-edge.js +219 -0
  304. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  305. package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
  306. package/lib/stdlib/behavior/drag-canvas.js +78 -33
  307. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  308. package/lib/stdlib/behavior/drag-combo.d.ts +3 -3
  309. package/lib/stdlib/behavior/drag-combo.js +43 -32
  310. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  311. package/lib/stdlib/behavior/drag-node.d.ts +4 -4
  312. package/lib/stdlib/behavior/drag-node.js +80 -63
  313. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  314. package/lib/stdlib/behavior/index.d.ts +3 -0
  315. package/lib/stdlib/behavior/index.js +3 -0
  316. package/lib/stdlib/behavior/index.js.map +1 -1
  317. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  318. package/lib/stdlib/behavior/lasso-select.js +6 -4
  319. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  320. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  321. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  322. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  323. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  324. package/lib/stdlib/behavior/shortcuts-call.js +91 -0
  325. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  326. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  327. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  328. package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
  329. package/lib/stdlib/behavior/zoom-canvas.js +70 -26
  330. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  331. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  332. package/lib/stdlib/data/mapNodeSize.js +2 -2
  333. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  334. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  335. package/lib/stdlib/data/transformV4Data.js +2 -2
  336. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  337. package/lib/stdlib/data/validateData.d.ts +2 -2
  338. package/lib/stdlib/data/validateData.js +13 -12
  339. package/lib/stdlib/data/validateData.js.map +1 -1
  340. package/lib/stdlib/index.d.ts +18 -6
  341. package/lib/stdlib/index.js +22 -10
  342. package/lib/stdlib/index.js.map +1 -1
  343. package/lib/stdlib/item/edge/base.d.ts +3 -5
  344. package/lib/stdlib/item/edge/base.js +30 -29
  345. package/lib/stdlib/item/edge/base.js.map +1 -1
  346. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  347. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  348. package/lib/stdlib/item/edge/cubic.js +2 -2
  349. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  350. package/lib/stdlib/item/edge/loop.js +3 -3
  351. package/lib/stdlib/item/edge/loop.js.map +1 -1
  352. package/lib/stdlib/item/node/base.d.ts +3 -6
  353. package/lib/stdlib/item/node/base.js +29 -59
  354. package/lib/stdlib/item/node/base.js.map +1 -1
  355. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  356. package/lib/stdlib/item/node/base3d.js +1 -0
  357. package/lib/stdlib/item/node/base3d.js.map +1 -1
  358. package/lib/stdlib/item/node/cube.d.ts +35 -0
  359. package/lib/stdlib/item/node/cube.js +58 -0
  360. package/lib/stdlib/item/node/cube.js.map +1 -0
  361. package/lib/stdlib/item/node/diamond.js +1 -1
  362. package/lib/stdlib/item/node/donut.d.ts +3 -3
  363. package/lib/stdlib/item/node/ellipse.js +2 -2
  364. package/lib/stdlib/item/node/hexagon.js +6 -2
  365. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  366. package/lib/stdlib/item/node/image.d.ts +40 -0
  367. package/lib/stdlib/item/node/image.js +114 -0
  368. package/lib/stdlib/item/node/image.js.map +1 -0
  369. package/lib/stdlib/item/node/index.d.ts +4 -0
  370. package/lib/stdlib/item/node/index.js +4 -0
  371. package/lib/stdlib/item/node/index.js.map +1 -1
  372. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  373. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  374. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  375. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  376. package/lib/stdlib/plugin/grid/index.js +6 -7
  377. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  378. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  379. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  380. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  381. package/lib/stdlib/plugin/history/index.js +14 -14
  382. package/lib/stdlib/plugin/history/index.js.map +1 -1
  383. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  384. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  385. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  386. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  387. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  388. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  389. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  390. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  391. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  392. package/lib/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  393. package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
  394. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  395. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  396. package/lib/stdlib/plugin/hull/util.js +26 -22
  397. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  398. package/lib/stdlib/plugin/index.d.ts +2 -0
  399. package/lib/stdlib/plugin/index.js +2 -0
  400. package/lib/stdlib/plugin/index.js.map +1 -1
  401. package/lib/stdlib/plugin/legend/index.d.ts +3 -3
  402. package/lib/stdlib/plugin/legend/index.js +3 -3
  403. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  404. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  405. package/lib/stdlib/plugin/menu/index.js +6 -6
  406. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  407. package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
  408. package/lib/stdlib/plugin/minimap/index.js +121 -14
  409. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  410. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  411. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  412. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  413. package/lib/stdlib/plugin/timebar/index.d.ts +4 -4
  414. package/lib/stdlib/plugin/timebar/index.js +6 -6
  415. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  416. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  417. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  418. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  419. package/lib/stdlib/plugin/tooltip/index.d.ts +5 -5
  420. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  421. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  422. package/lib/stdlib/plugin/types.d.ts +2 -0
  423. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  424. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  425. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  426. package/lib/stdlib/theme/dark.js +42 -2
  427. package/lib/stdlib/theme/dark.js.map +1 -1
  428. package/lib/stdlib/theme/light.js +4 -4
  429. package/lib/types/animate.d.ts +2 -2
  430. package/lib/types/behavior.d.ts +1 -1
  431. package/lib/types/combo.d.ts +7 -7
  432. package/lib/types/common.d.ts +5 -5
  433. package/lib/types/data.d.ts +6 -6
  434. package/lib/types/edge.d.ts +9 -9
  435. package/lib/types/event.d.ts +2 -1
  436. package/lib/types/event.js +2 -2
  437. package/lib/types/event.js.map +1 -1
  438. package/lib/types/graph.d.ts +48 -22
  439. package/lib/types/history.d.ts +2 -2
  440. package/lib/types/history.js +1 -1
  441. package/lib/types/history.js.map +1 -1
  442. package/lib/types/hook.d.ts +23 -3
  443. package/lib/types/index.d.ts +2 -1
  444. package/lib/types/index.js +3 -1
  445. package/lib/types/index.js.map +1 -1
  446. package/lib/types/item.d.ts +18 -12
  447. package/lib/types/item.js +1 -1
  448. package/lib/types/item.js.map +1 -1
  449. package/lib/types/layout.d.ts +6 -6
  450. package/lib/types/loop.d.ts +2 -2
  451. package/lib/types/loop.js +1 -1
  452. package/lib/types/loop.js.map +1 -1
  453. package/lib/types/node.d.ts +7 -7
  454. package/lib/types/plugin.d.ts +1 -1
  455. package/lib/types/render.d.ts +1 -1
  456. package/lib/types/spec.d.ts +19 -3
  457. package/lib/types/stdlib.d.ts +1 -1
  458. package/lib/types/theme.d.ts +8 -8
  459. package/lib/types/view.d.ts +7 -2
  460. package/lib/util/bbox.d.ts +16 -1
  461. package/lib/util/bbox.js +36 -6
  462. package/lib/util/bbox.js.map +1 -1
  463. package/lib/util/behavior.d.ts +2 -2
  464. package/lib/util/behavior.js +2 -2
  465. package/lib/util/behavior.js.map +1 -1
  466. package/lib/util/data.d.ts +2 -2
  467. package/lib/util/data.js.map +1 -1
  468. package/lib/util/dom.d.ts +15 -0
  469. package/lib/util/dom.js +34 -0
  470. package/lib/util/dom.js.map +1 -0
  471. package/lib/util/event.d.ts +5 -3
  472. package/lib/util/event.js +8 -1
  473. package/lib/util/event.js.map +1 -1
  474. package/lib/util/extend.d.ts +1 -1
  475. package/lib/util/extend.js +0 -1
  476. package/lib/util/extend.js.map +1 -1
  477. package/lib/util/index.d.ts +7 -52
  478. package/lib/util/index.js +23 -23
  479. package/lib/util/index.js.map +1 -1
  480. package/lib/util/item.d.ts +16 -1
  481. package/lib/util/item.js +33 -9
  482. package/lib/util/item.js.map +1 -1
  483. package/lib/util/layout.d.ts +13 -2
  484. package/lib/util/layout.js +47 -1
  485. package/lib/util/layout.js.map +1 -1
  486. package/lib/util/loop.d.ts +1 -1
  487. package/lib/util/loop.js +4 -0
  488. package/lib/util/loop.js.map +1 -1
  489. package/lib/util/math.d.ts +1 -1
  490. package/lib/util/matrix.d.ts +6 -0
  491. package/lib/util/matrix.js +52 -0
  492. package/lib/util/matrix.js.map +1 -0
  493. package/lib/util/path.js +2 -2
  494. package/lib/util/path.js.map +1 -1
  495. package/lib/util/point.d.ts +1 -1
  496. package/lib/util/point.js +9 -2
  497. package/lib/util/point.js.map +1 -1
  498. package/lib/util/polyline.d.ts +2 -1
  499. package/lib/util/polyline.js +2 -1
  500. package/lib/util/polyline.js.map +1 -1
  501. package/lib/util/router.d.ts +1 -1
  502. package/lib/util/shape.d.ts +1 -2
  503. package/lib/util/shape.js +16 -26
  504. package/lib/util/shape.js.map +1 -1
  505. package/lib/util/shape3d.js +15 -16
  506. package/lib/util/shape3d.js.map +1 -1
  507. package/lib/util/text.d.ts +1 -1
  508. package/lib/util/text.js +3 -2
  509. package/lib/util/text.js.map +1 -1
  510. package/lib/util/warn.d.ts +14 -0
  511. package/lib/util/warn.js +8 -0
  512. package/lib/util/warn.js.map +1 -0
  513. package/package.json +41 -50
  514. package/src/api-doc/graph.ts +4 -3
  515. package/src/api-doc/types.ts +1 -0
  516. package/src/constant/shape.ts +1 -1
  517. package/src/index.ts +5 -6
  518. package/src/item/combo.ts +16 -15
  519. package/src/item/edge.ts +135 -57
  520. package/src/item/item.ts +32 -19
  521. package/src/item/node.ts +36 -50
  522. package/src/runtime/controller/data.ts +140 -339
  523. package/src/runtime/controller/interaction.ts +10 -4
  524. package/src/runtime/controller/item.ts +261 -78
  525. package/src/runtime/controller/layout.ts +1 -5
  526. package/src/runtime/controller/plugin.ts +15 -4
  527. package/src/runtime/graph.ts +605 -103
  528. package/src/stdlib/behavior/activate-relations.ts +2 -2
  529. package/src/stdlib/behavior/brush-select.ts +14 -13
  530. package/src/stdlib/behavior/click-select.ts +1 -1
  531. package/src/stdlib/behavior/create-edge.ts +305 -0
  532. package/src/stdlib/behavior/drag-canvas.ts +107 -35
  533. package/src/stdlib/behavior/drag-combo.ts +10 -10
  534. package/src/stdlib/behavior/drag-node.ts +27 -18
  535. package/src/stdlib/behavior/index.ts +3 -0
  536. package/src/stdlib/behavior/lasso-select.ts +7 -5
  537. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  538. package/src/stdlib/behavior/shortcuts-call.ts +129 -0
  539. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  540. package/src/stdlib/behavior/zoom-canvas.ts +98 -27
  541. package/src/stdlib/data/mapNodeSize.ts +2 -2
  542. package/src/stdlib/data/transformV4Data.ts +2 -2
  543. package/src/stdlib/data/validateData.ts +16 -16
  544. package/src/stdlib/index.ts +28 -7
  545. package/src/stdlib/item/edge/base.ts +32 -41
  546. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  547. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  548. package/src/stdlib/item/edge/cubic.ts +1 -1
  549. package/src/stdlib/item/edge/loop.ts +1 -1
  550. package/src/stdlib/item/node/base.ts +38 -65
  551. package/src/stdlib/item/node/base3d.ts +1 -0
  552. package/src/stdlib/item/node/cube.ts +102 -0
  553. package/src/stdlib/item/node/diamond.ts +1 -1
  554. package/src/stdlib/item/node/ellipse.ts +2 -2
  555. package/src/stdlib/item/node/hexagon.ts +6 -2
  556. package/src/stdlib/item/node/image.ts +190 -0
  557. package/src/stdlib/item/node/index.ts +4 -0
  558. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  559. package/src/stdlib/plugin/grid/index.ts +6 -6
  560. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  561. package/src/stdlib/plugin/history/index.ts +14 -14
  562. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  563. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  564. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  565. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  566. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  567. package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
  568. package/src/stdlib/plugin/hull/util.ts +6 -2
  569. package/src/stdlib/plugin/index.ts +2 -0
  570. package/src/stdlib/plugin/legend/index.ts +6 -6
  571. package/src/stdlib/plugin/menu/index.ts +13 -13
  572. package/src/stdlib/plugin/minimap/index.ts +126 -16
  573. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  574. package/src/stdlib/plugin/timebar/index.ts +4 -4
  575. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  576. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  577. package/src/stdlib/plugin/types.ts +2 -0
  578. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  579. package/src/stdlib/theme/dark.ts +66 -2
  580. package/src/stdlib/theme/light.ts +4 -4
  581. package/src/types/event.ts +1 -0
  582. package/src/types/graph.ts +62 -25
  583. package/src/types/hook.ts +22 -2
  584. package/src/types/index.ts +2 -1
  585. package/src/types/item.ts +10 -0
  586. package/src/types/plugin.ts +1 -1
  587. package/src/types/spec.ts +22 -3
  588. package/src/types/view.ts +8 -3
  589. package/src/util/bbox.ts +42 -6
  590. package/src/util/behavior.ts +4 -4
  591. package/src/util/data.ts +2 -3
  592. package/src/util/dom.ts +33 -0
  593. package/src/util/event.ts +14 -1
  594. package/src/util/extend.ts +2 -3
  595. package/src/util/index.ts +7 -24
  596. package/src/util/item.ts +65 -28
  597. package/src/util/layout.ts +48 -2
  598. package/src/util/loop.ts +5 -1
  599. package/src/util/math.ts +1 -1
  600. package/src/util/matrix.ts +66 -0
  601. package/src/util/path.ts +1 -1
  602. package/src/util/point.ts +9 -4
  603. package/src/util/polyline.ts +2 -1
  604. package/src/util/router.ts +1 -1
  605. package/src/util/shape.ts +22 -26
  606. package/src/util/shape3d.ts +20 -20
  607. package/src/util/text.ts +3 -1
  608. package/src/util/warn.ts +20 -0
@@ -125,6 +125,7 @@ export class DragNode extends Behavior {
125
125
  'node:pointerdown': this.onPointerDown,
126
126
  pointermove: this.onPointerMove,
127
127
  click: this.onClick,
128
+ 'node:pointerup': this.onPointerUp,
128
129
  // FIXME: IG6Event -> keyboard event
129
130
  keydown: this.onKeydown as any,
130
131
  };
@@ -198,6 +199,14 @@ export class DragNode extends Behavior {
198
199
  if (!this.options.shouldBegin(event)) return;
199
200
  this.pointerDown = { x: event.canvas.x, y: event.canvas.y };
200
201
  this.dragging = false;
202
+
203
+ document.addEventListener(
204
+ 'mouseup',
205
+ (evt) => {
206
+ this.onPointerUp(event);
207
+ },
208
+ { once: true },
209
+ );
201
210
  }
202
211
 
203
212
  public onPointerMove(event: IG6GraphEvent) {
@@ -258,7 +267,7 @@ export class DragNode extends Behavior {
258
267
  this.selectedNodeIds,
259
268
  this.hiddenComboTreeItems,
260
269
  );
261
- this.graph.executeWithoutStacking(() => {
270
+ this.graph.executeWithNoStack(() => {
262
271
  this.graph.hideItem(
263
272
  this.hiddenEdges.map((edge) => edge.id),
264
273
  true,
@@ -292,7 +301,7 @@ export class DragNode extends Behavior {
292
301
  });
293
302
 
294
303
  // Hide original edges and nodes. They will be restored when pointerup.
295
- this.graph.executeWithoutStacking(() => {
304
+ this.graph.executeWithNoStack(() => {
296
305
  this.graph.hideItem(this.selectedNodeIds, true);
297
306
  this.graph.hideItem(
298
307
  this.hiddenEdges.map((edge) => edge.id),
@@ -457,7 +466,7 @@ export class DragNode extends Behavior {
457
466
  this.graph.drawTransient('rect', DELEGATE_SHAPE_ID, { action: 'remove' });
458
467
  }
459
468
 
460
- public clearTransientItems() {
469
+ public clearTransientItems(positions: Array<Position>) {
461
470
  this.hiddenEdges.forEach((edge) => {
462
471
  this.graph.drawTransient('node', edge.source, { action: 'remove' });
463
472
  this.graph.drawTransient('node', edge.target, { action: 'remove' });
@@ -472,13 +481,13 @@ export class DragNode extends Behavior {
472
481
  action: 'remove',
473
482
  });
474
483
  });
475
- this.originPositions.forEach(({ id }) => {
484
+ positions.forEach(({ id }) => {
476
485
  this.graph.drawTransient('node', id, { action: 'remove' });
477
486
  });
478
487
  }
479
488
 
480
489
  public restoreHiddenItems(positions?: Position[]) {
481
- this.graph.pauseStacking();
490
+ this.graph.pauseStack();
482
491
  if (this.hiddenEdges.length) {
483
492
  this.graph.showItem(
484
493
  this.hiddenEdges.map((edge) => edge.id),
@@ -508,7 +517,7 @@ export class DragNode extends Behavior {
508
517
  true,
509
518
  );
510
519
  }
511
- this.graph.resumeStacking();
520
+ this.graph.resumeStack();
512
521
  }
513
522
 
514
523
  public clearState() {
@@ -543,7 +552,7 @@ export class DragNode extends Behavior {
543
552
  debounce((positions) => {
544
553
  // restore the hidden items after move real nodes done
545
554
  if (enableTransient) {
546
- this.clearTransientItems();
555
+ this.clearTransientItems(positions);
547
556
  }
548
557
 
549
558
  if (this.options.enableDelegate) {
@@ -573,7 +582,7 @@ export class DragNode extends Behavior {
573
582
  return;
574
583
  }
575
584
  this.clearDelegate();
576
- this.clearTransientItems();
585
+ this.clearTransientItems(this.originPositions);
577
586
  this.restoreHiddenItems();
578
587
 
579
588
  const enableTransient =
@@ -589,8 +598,8 @@ export class DragNode extends Behavior {
589
598
  this.clearState();
590
599
  }
591
600
 
592
- public onDropNode(event: IG6GraphEvent) {
593
- const elements = this.graph.canvas.document.elementsFromPointSync(
601
+ public async onDropNode(event: IG6GraphEvent) {
602
+ const elements = await this.graph.canvas.document.elementsFromPoint(
594
603
  event.canvas.x,
595
604
  event.canvas.y,
596
605
  );
@@ -608,7 +617,7 @@ export class DragNode extends Behavior {
608
617
  ? this.graph.getNodeData(dropId).data.parentId
609
618
  : dropId;
610
619
 
611
- this.graph.startBatch();
620
+ this.graph.startHistoryBatch();
612
621
  this.originPositions.forEach(({ id }) => {
613
622
  const model = this.graph.getNodeData(id);
614
623
  if (!model) return;
@@ -621,13 +630,13 @@ export class DragNode extends Behavior {
621
630
  this.graph.updateData('node', { id, data: { parentId: newParentId } });
622
631
  });
623
632
  this.onPointerUp(event);
624
- this.graph.stopBatch();
633
+ this.graph.stopHistoryBatch();
625
634
  }
626
635
 
627
636
  public onDropCombo(event: IG6GraphEvent) {
628
637
  event.stopPropagation();
629
638
  const newParentId = event.itemId;
630
- this.graph.startBatch();
639
+ this.graph.startHistoryBatch();
631
640
  this.onPointerUp(event);
632
641
  this.originPositions.forEach(({ id }) => {
633
642
  const model = this.graph.getNodeData(id);
@@ -637,11 +646,11 @@ export class DragNode extends Behavior {
637
646
  this.graph.updateData('node', { id, data: { parentId: newParentId } });
638
647
  });
639
648
  this.clearState();
640
- this.graph.stopBatch();
649
+ this.graph.stopHistoryBatch();
641
650
  }
642
651
 
643
- public onDropCanvas(event: IG6GraphEvent) {
644
- const elements = this.graph.canvas.document.elementsFromPointSync(
652
+ public async onDropCanvas(event: IG6GraphEvent) {
653
+ const elements = await this.graph.canvas.document.elementsFromPoint(
645
654
  event.canvas.x,
646
655
  event.canvas.y,
647
656
  );
@@ -657,7 +666,7 @@ export class DragNode extends Behavior {
657
666
  const parentId = this.graph.getNodeData(dropId)
658
667
  ? this.graph.getNodeData(dropId).data.parentId
659
668
  : dropId;
660
- this.graph.startBatch();
669
+ this.graph.startHistoryBatch();
661
670
  this.onPointerUp(event);
662
671
  const nodeToUpdate = [];
663
672
  this.originPositions.forEach(({ id }) => {
@@ -671,6 +680,6 @@ export class DragNode extends Behavior {
671
680
  });
672
681
  if (nodeToUpdate.length) this.graph.updateData('node', nodeToUpdate);
673
682
  this.clearState();
674
- this.graph.stopBatch();
683
+ this.graph.stopHistoryBatch();
675
684
  }
676
685
  }
@@ -13,3 +13,6 @@ export * from './orbit-canvas-3d';
13
13
  export * from './rotate-canvas-3d';
14
14
  export * from './track-canvas-3d';
15
15
  export * from './zoom-canvas-3d';
16
+ export * from './create-edge';
17
+ export * from './shortcuts-call';
18
+ export * from './scroll-canvas';
@@ -1,7 +1,7 @@
1
1
  import { DisplayObject } from '@antv/g';
2
2
  import { ID } from '@antv/graphlib';
3
3
  import { IG6GraphEvent } from '../../types/event';
4
- import { utils } from '..';
4
+ import lassoSelector from '../selector/lasso';
5
5
  import { Point } from '../../types/common';
6
6
  import { IGraph } from '../../types';
7
7
  import { BrushSelect } from './brush-select';
@@ -50,7 +50,7 @@ export class LassoSelect extends BrushSelect {
50
50
  };
51
51
 
52
52
  public getSelector() {
53
- return utils.lassoSelector;
53
+ return lassoSelector;
54
54
  }
55
55
 
56
56
  public getPoints() {
@@ -61,8 +61,10 @@ export class LassoSelect extends BrushSelect {
61
61
  const { graph, options } = this;
62
62
  const { brushStyle } = options;
63
63
  return graph.drawTransient('path', LASSO_SHAPE_ID, {
64
- style: brushStyle,
65
- capture: false,
64
+ style: {
65
+ pointerEvents: 'none',
66
+ ...brushStyle,
67
+ },
66
68
  });
67
69
  }
68
70
 
@@ -82,7 +84,7 @@ export class LassoSelect extends BrushSelect {
82
84
 
83
85
  getLassoPath = () => {
84
86
  const points: Point[] = this.points;
85
- const path = [];
87
+ const path: any = [];
86
88
  if (points.length) {
87
89
  points.forEach((point, index) => {
88
90
  if (index === 0) {
@@ -0,0 +1,348 @@
1
+ import { isBoolean, isNumber, isObject } from '@antv/util';
2
+ import { Behavior } from '../../types/behavior';
3
+ import { ID, IG6GraphEvent } from '../../types';
4
+
5
+ interface ScrollCanvasOptions {
6
+ /**
7
+ * The direction of dragging that is allowed. Options: 'x', 'y', 'both'. 'both' by default.
8
+ */
9
+ direction?: string;
10
+ /**
11
+ * Whether enable optimize strategies, which will hide all the shapes excluding node keyShape while scrolling.
12
+ */
13
+ enableOptimize?: boolean;
14
+ /**
15
+ * When the zoom ratio of the graph is smaller than ```optimizeZoom```, all shapes except for node keyShape will always be hidden.
16
+ * This option requires ```enableOptimize=true```;
17
+ */
18
+ optimizeZoom?: number;
19
+ /**
20
+ * Switch to zooming while pressing the key and wheeling. Options: 'shift', 'ctrl', 'alt', 'control', 'meta', using an array of these options allows any of these keys to trigger zooming;
21
+ * Use ```'ctrl'``` by default;
22
+ */
23
+ zoomKey?: string | string[];
24
+ /** Switch to zooming while pressing the key and wheeling. This option allows you to control the zoom ratio for each event.
25
+ * Use ```'0.05'``` by default;
26
+ */
27
+ zoomRatio?: number;
28
+ /**
29
+ * The range of canvas to limit dragging, 0 by default, which means the graph cannot be dragged totally out of the view port range.
30
+ * If scalableRange is number or a string without 'px', means it is a ratio of the graph content.
31
+ * If scalableRange is a string with 'px', it is regarded as pixels.
32
+ * If scalableRange = 0, no constrains;
33
+ * If scalableRange > 0, the graph can be dragged out of the view port range
34
+ * If scalableRange < 0, the range is smaller than the view port.
35
+ * Refer to https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ
36
+ */
37
+ scalableRange?: string | number;
38
+ /**
39
+ * Whether allow trigger this behavior when drag start on nodes / edges / combos.
40
+ */
41
+ allowDragOnItem?:
42
+ | boolean
43
+ | {
44
+ node?: boolean;
45
+ edge?: boolean;
46
+ combo?: boolean;
47
+ };
48
+ }
49
+
50
+ const DEFAULT_OPTIONS: ScrollCanvasOptions = {
51
+ direction: 'both',
52
+ enableOptimize: false,
53
+ zoomKey: 'ctrl',
54
+ scalableRange: 0,
55
+ allowDragOnItem: true,
56
+ zoomRatio: 0.05,
57
+ };
58
+
59
+ export class ScrollCanvas extends Behavior {
60
+ private hiddenEdgeIds: ID[];
61
+ private hiddenNodeIds: ID[];
62
+
63
+ declare options: ScrollCanvasOptions;
64
+ timeout?: number;
65
+ optimized = false;
66
+ constructor(options: Partial<ScrollCanvasOptions>) {
67
+ const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options, {
68
+ zoomKey: initZoomKey(options.zoomKey),
69
+ });
70
+ super(finalOptions);
71
+ }
72
+
73
+ getEvents = () => {
74
+ return {
75
+ wheel: this.onWheel,
76
+ };
77
+ };
78
+
79
+ onWheel(ev: IG6GraphEvent & { deltaX?: number; deltaY?: number }) {
80
+ if (!this.allowDrag(ev)) return;
81
+ const graph = this.graph;
82
+ const { zoomKey, zoomRatio, enableOptimize } = this.options;
83
+ const zoomKeys = Array.isArray(zoomKey) ? [].concat(zoomKey) : [zoomKey];
84
+ if (zoomKeys.includes('control')) zoomKeys.push('ctrl');
85
+ const keyDown = zoomKeys.some((ele) => ev[`${ele}Key`]);
86
+
87
+ const nativeEvent = ev.nativeEvent as
88
+ | (WheelEvent & { wheelDelta: number })
89
+ | undefined;
90
+
91
+ if (keyDown) {
92
+ const canvas = graph.canvas;
93
+ const point = canvas.client2Viewport({ x: ev.client.x, y: ev.client.y });
94
+ let ratio = graph.getZoom();
95
+ if (nativeEvent && nativeEvent.wheelDelta > 0) {
96
+ ratio = ratio + ratio * zoomRatio;
97
+ } else {
98
+ ratio = ratio - ratio * zoomRatio;
99
+ }
100
+ graph.zoomTo(ratio, {
101
+ x: point.x,
102
+ y: point.y,
103
+ });
104
+ } else {
105
+ const diffX = ev.deltaX || ev.movement.x;
106
+ const diffY = ev.deltaY || ev.movement.y;
107
+
108
+ const { dx, dy } = this.formatDisplacement(diffX, diffY);
109
+ graph.translate({ dx: -dx, dy: -dy });
110
+ }
111
+
112
+ if (enableOptimize) {
113
+ const optimized = this.optimized;
114
+
115
+ // hiding
116
+ if (!optimized) {
117
+ this.hideShapes();
118
+ this.optimized = true;
119
+ }
120
+
121
+ // showing after 100ms
122
+ clearTimeout(this.timeout);
123
+ this.timeout = undefined;
124
+ const timeout = window.setTimeout(() => {
125
+ this.showShapes();
126
+ this.optimized = false;
127
+ }, 100);
128
+ this.timeout = timeout;
129
+ }
130
+ }
131
+ private formatDisplacement(dx: number, dy: number) {
132
+ const { graph } = this;
133
+ const { scalableRange, direction } = this.options;
134
+ const [width, height] = graph.getSize();
135
+ const graphBBox = graph.canvas.getRoot().getRenderBounds();
136
+ let rangeNum = Number(scalableRange);
137
+ let isPixel;
138
+ if (typeof scalableRange === 'string') {
139
+ if (scalableRange.includes('px')) {
140
+ isPixel = scalableRange.includes('px');
141
+ rangeNum = Number(scalableRange.replace('px', ''));
142
+ }
143
+ if (scalableRange.includes('%')) {
144
+ rangeNum = Number(scalableRange.replace('%', '')) / 100;
145
+ }
146
+ }
147
+
148
+ let expandWidth = rangeNum;
149
+ let expandHeight = rangeNum;
150
+ // If it is not a string with 'px', regard as ratio
151
+ if (!isPixel) {
152
+ expandWidth = width * rangeNum;
153
+ expandHeight = height * rangeNum;
154
+ }
155
+ const leftTopClient = graph.getViewportByCanvas({
156
+ x: graphBBox.min[0],
157
+ y: graphBBox.min[1],
158
+ });
159
+ const rightBottomClient = graph.getViewportByCanvas({
160
+ x: graphBBox.max[0],
161
+ y: graphBBox.max[1],
162
+ });
163
+ const minX = leftTopClient.x;
164
+ const minY = leftTopClient.y;
165
+ const maxX = rightBottomClient.x;
166
+ const maxY = rightBottomClient.y;
167
+ if (dx > 0) {
168
+ if (maxX < -expandWidth) {
169
+ dx = 0;
170
+ } else if (maxX - dx < -expandWidth) {
171
+ dx = maxX + expandWidth;
172
+ }
173
+ } else if (dx < 0) {
174
+ if (minX > width + expandWidth) {
175
+ dx = 0;
176
+ } else if (minX - dx > width + expandWidth) {
177
+ dx = minX - (width + expandWidth);
178
+ }
179
+ }
180
+
181
+ if (dy > 0) {
182
+ if (maxY < -expandHeight) {
183
+ dy = 0;
184
+ } else if (maxY - dy < -expandHeight) {
185
+ dy = maxY + expandHeight;
186
+ }
187
+ } else if (dy < 0) {
188
+ if (minY > height + expandHeight) {
189
+ dy = 0;
190
+ } else if (minY - dy > height + expandHeight) {
191
+ dy = minY - (height + expandHeight);
192
+ }
193
+ }
194
+
195
+ if (direction === 'x') {
196
+ dy = 0;
197
+ } else if (direction === 'y') {
198
+ dx = 0;
199
+ }
200
+
201
+ return { dx, dy };
202
+ }
203
+
204
+ private allowDrag(evt: IG6GraphEvent) {
205
+ const { itemType } = evt;
206
+ const { allowDragOnItem } = this.options;
207
+ const targetIsCanvas = itemType === 'canvas';
208
+ if (isBoolean(allowDragOnItem) && !allowDragOnItem && !targetIsCanvas)
209
+ return false;
210
+ if (isObject(allowDragOnItem)) {
211
+ const { node, edge, combo } = allowDragOnItem;
212
+ if (!node && itemType === 'node') return false;
213
+ if (!edge && itemType === 'edge') return false;
214
+ if (!combo && itemType === 'combo') return false;
215
+ }
216
+ return true;
217
+ }
218
+
219
+ private hideShapes() {
220
+ const { graph, options } = this;
221
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
222
+ graph.getSpecification().optimize || {};
223
+ const { optimizeZoom } = options;
224
+ const optimize = this.options.enableOptimize || graphBehaviorOptimize;
225
+ const shouldOptimzie = isNumber(optimize)
226
+ ? graph.getAllNodesData().length > optimize
227
+ : optimize;
228
+ if (shouldOptimzie) {
229
+ const currentZoom = graph.getZoom();
230
+ const newHiddenEdgeIds = graph
231
+ .getAllEdgesData()
232
+ .map((edge) => edge.id)
233
+ .filter((id) => graph.getItemVisible(id));
234
+ graph.hideItem(newHiddenEdgeIds, true);
235
+
236
+ if (currentZoom < optimizeZoom) {
237
+ this.hiddenEdgeIds.push(...newHiddenEdgeIds);
238
+ } else {
239
+ this.hiddenEdgeIds = newHiddenEdgeIds;
240
+ }
241
+
242
+ const newHiddenNodeIds = graph
243
+ .getAllNodesData()
244
+ .map((node) => node.id)
245
+ .filter((id) => graph.getItemVisible(id));
246
+
247
+ let requestId;
248
+ const sectionNum = Math.ceil(newHiddenNodeIds.length / tileBehaviorSize);
249
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
250
+ newHiddenNodeIds.slice(
251
+ i * tileBehaviorSize,
252
+ i * tileBehaviorSize + tileBehaviorSize,
253
+ ),
254
+ );
255
+ const update = () => {
256
+ if (!sections.length) {
257
+ cancelAnimationFrame(requestId);
258
+ return;
259
+ }
260
+ const section = sections.shift();
261
+ graph.startHistoryBatch();
262
+ graph.hideItem(section, false, true);
263
+ graph.stopHistoryBatch();
264
+ requestId = requestAnimationFrame(update);
265
+ };
266
+ requestId = requestAnimationFrame(update);
267
+
268
+ if (currentZoom < optimizeZoom) {
269
+ this.hiddenNodeIds.push(...newHiddenNodeIds);
270
+ } else {
271
+ this.hiddenNodeIds = newHiddenNodeIds;
272
+ }
273
+ }
274
+ }
275
+ private showShapes() {
276
+ const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
277
+ const currentZoom = graph.getZoom();
278
+ const { optimizeZoom } = this.options;
279
+
280
+ // hide the shapes when the zoom ratio is smaller than optimizeZoom
281
+ // hide the shapes when zoomming
282
+ if (currentZoom < optimizeZoom) {
283
+ return;
284
+ }
285
+
286
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
287
+ graph.getSpecification().optimize || {};
288
+ const optimize = this.options.enableOptimize || graphBehaviorOptimize;
289
+ const shouldOptimzie = isNumber(optimize)
290
+ ? graph.getAllNodesData().length > optimize
291
+ : optimize;
292
+ if (!shouldOptimzie) {
293
+ this.hiddenEdgeIds = this.hiddenNodeIds = [];
294
+ return;
295
+ }
296
+
297
+ let requestId;
298
+ const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
299
+ const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
300
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
301
+ hiddenIds.slice(
302
+ i * tileBehaviorSize,
303
+ i * tileBehaviorSize + tileBehaviorSize,
304
+ ),
305
+ );
306
+ const update = () => {
307
+ if (!sections.length) {
308
+ cancelAnimationFrame(requestId);
309
+ return;
310
+ }
311
+ graph.executeWithNoStack(() => {
312
+ graph.showItem(sections.shift(), false);
313
+ });
314
+ requestId = requestAnimationFrame(update);
315
+ };
316
+ requestId = requestAnimationFrame(update);
317
+
318
+ this.hiddenEdgeIds = this.hiddenNodeIds = [];
319
+ }
320
+ }
321
+
322
+ const ALLOW_EVENTS = ['shift', 'ctrl', 'alt', 'control', 'meta'];
323
+
324
+ function initZoomKey(zoomKey?: string | string[]) {
325
+ const zoomKeys = zoomKey
326
+ ? Array.isArray(zoomKey)
327
+ ? zoomKey
328
+ : [zoomKey]
329
+ : [];
330
+
331
+ const validZoomKeys = zoomKeys.filter((zoomKey) => {
332
+ const keyIsValid = ALLOW_EVENTS.includes(zoomKey);
333
+ if (!keyIsValid)
334
+ console.warn(
335
+ `Invalid zoomKey: ${zoomKey}, please use a valid zoomKey: ${JSON.stringify(
336
+ ALLOW_EVENTS,
337
+ )}`,
338
+ );
339
+
340
+ return keyIsValid;
341
+ });
342
+
343
+ if (validZoomKeys.length === 0) {
344
+ validZoomKeys.push('ctrl');
345
+ }
346
+
347
+ return validZoomKeys;
348
+ }
@@ -0,0 +1,129 @@
1
+ import type { IG6GraphEvent } from '../../types';
2
+ import { Behavior } from '../../types/behavior';
3
+
4
+ const DEFAULT_TRIGGER = 'ctrl';
5
+ const ALLOW_TRIGGERS = ['shift', 'ctrl', 'alt', 'control'] as const;
6
+ const DEFAULT_COMBINED_KEY = '1';
7
+ type Trigger = (typeof ALLOW_TRIGGERS)[number];
8
+
9
+ interface ShortcutsCallOptions {
10
+ /**
11
+ * The main key to pressed to apply shortcuts call
12
+ * Defaults to `"ctrl"`.
13
+ */
14
+ trigger?: Trigger;
15
+ /**
16
+ * The combined key to pressed with trigger to apply shortcuts call.
17
+ * Defaults to `"1"`.
18
+ */
19
+ combinedKey?: string;
20
+ /**
21
+ *
22
+ * The function to be called.
23
+ * Defaults to `"fitView"`.
24
+ *
25
+ */
26
+ functionName?: string;
27
+ /**
28
+ * The function params.
29
+ */
30
+ functionParams?: any[];
31
+ }
32
+
33
+ const DEFAULT_OPTIONS: ShortcutsCallOptions = {
34
+ trigger: DEFAULT_TRIGGER,
35
+ combinedKey: DEFAULT_COMBINED_KEY,
36
+ functionName: 'fitView',
37
+ functionParams: [],
38
+ };
39
+
40
+ export class ShortcutsCall extends Behavior {
41
+ triggerKeydown = false;
42
+
43
+ constructor(options: Partial<ShortcutsCallOptions>) {
44
+ super(Object.assign({}, DEFAULT_OPTIONS, options));
45
+ // Validate options
46
+ if (options.trigger && !ALLOW_TRIGGERS.includes(options.trigger)) {
47
+ console.warn(
48
+ `G6: Invalid trigger option "${options.trigger}" for shortcuts-call behavior!`,
49
+ );
50
+ this.options.trigger = DEFAULT_OPTIONS.trigger;
51
+ }
52
+ if (options.combinedKey === this.options.trigger) {
53
+ this.options.combinedKey = undefined;
54
+ }
55
+ }
56
+
57
+ getEvents = () => {
58
+ return {
59
+ keyup: this.onKeyUp,
60
+ keydown: this.onKeyDown,
61
+ };
62
+ };
63
+
64
+ public onKeyDown(e: IG6GraphEvent) {
65
+ const code = e.key;
66
+ if (!code) return;
67
+
68
+ const { graph } = this;
69
+ const { trigger, combinedKey, functionName, functionParams } = this.options;
70
+
71
+ const triggerLowerCase = trigger.toLowerCase();
72
+ const codeLowerCase = code.toLowerCase();
73
+ // While holding down the Control key, allow users to set the trigger as "ctrl".
74
+ if (!this.triggerKeydown) {
75
+ if (
76
+ codeLowerCase === triggerLowerCase ||
77
+ (codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
78
+ (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
79
+ ) {
80
+ this.triggerKeydown = true;
81
+ }
82
+ }
83
+
84
+ if (!graph[functionName]) {
85
+ console.warn(
86
+ `G6: Invalid functionName option: "${functionName}" for shortcuts-call behavior!`,
87
+ );
88
+ return {};
89
+ }
90
+ if (!this.triggerKeydown) return;
91
+
92
+ if (!combinedKey) {
93
+ if (functionParams && functionParams.length) {
94
+ graph[functionName](...functionParams);
95
+ } else {
96
+ graph[functionName]();
97
+ }
98
+ return;
99
+ }
100
+
101
+ const combinedKeyLowerCase = combinedKey.toLowerCase();
102
+ if (
103
+ codeLowerCase === combinedKeyLowerCase ||
104
+ (codeLowerCase === 'control' && combinedKeyLowerCase === 'ctrl') ||
105
+ (codeLowerCase === 'ctrl' && combinedKeyLowerCase === 'control')
106
+ ) {
107
+ if (functionParams && functionParams.length) {
108
+ graph[functionName](...functionParams);
109
+ } else {
110
+ graph[functionName]();
111
+ }
112
+ }
113
+ }
114
+
115
+ public onKeyUp(e) {
116
+ const code = e.key;
117
+ if (!code) return;
118
+ const { trigger } = this.options;
119
+ const triggerLowerCase = trigger.toLowerCase();
120
+ const codeLowerCase = code.toLowerCase();
121
+ if (
122
+ codeLowerCase === triggerLowerCase ||
123
+ (codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
124
+ (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
125
+ ) {
126
+ this.triggerKeydown = false;
127
+ }
128
+ }
129
+ }
@@ -123,7 +123,10 @@ export class ZoomCanvas3D extends Behavior {
123
123
  ((100 * sign * sensitivity) / currentDistance) *
124
124
  Math.sqrt(currentDistance);
125
125
  const toDistance = currentDistance + dolly;
126
- const cameraFrontOfFocalPoint = camera.getDistanceVector()[2] < 0;
126
+ const azimuth = camera.getAzimuth();
127
+ const isFlipped = azimuth < 90 && azimuth > -90 ? 1 : -1;
128
+ const distancePositive = camera.getDistanceVector()[2] < 0 ? 1 : -1;
129
+ const cameraFrontOfFocalPoint = isFlipped * distancePositive > 0;
127
130
 
128
131
  // zoom out constraint
129
132
  if (