1- import {
2- LinkDragMoveHelper ,
3- generateUUID ,
4- getArrowPoints ,
5- calcP1 ,
6- calcP4 ,
7- } from './utils/index'
1+ import { LinkDragMoveHelper , generateUUID , getArrowPoints , calcP1 , calcP4 } from './utils/index'
82import { createSvgGroup } from './utils/svg'
93
104// TODO Link label
11- export const createLink = function ( from , to , isInitPaint , obj ) {
5+ export const createLink = function ( from , to , isInitPaint , obj ) {
126 const map = this . map . getBoundingClientRect ( )
137 if ( ! from || ! to ) {
148 return // not expand
@@ -115,10 +109,12 @@ export const createLink = function(from, to, isInitPaint, obj) {
115109 this . currentLink = newSvgGroup
116110 }
117111 this . linkSvgGroup . appendChild ( newSvgGroup )
118- if ( ! isInitPaint ) { this . showLinkController ( p2x , p2y , p3x , p3y , newLinkObj , fromData , toData ) }
112+ if ( ! isInitPaint ) {
113+ this . showLinkController ( p2x , p2y , p3x , p3y , newLinkObj , fromData , toData )
114+ }
119115}
120116
121- export const removeLink = function ( linkSvg ) {
117+ export const removeLink = function ( linkSvg ) {
122118 let link
123119 if ( linkSvg ) {
124120 link = linkSvg
@@ -134,7 +130,7 @@ export const removeLink = function(linkSvg) {
134130 link . remove ( )
135131 link = null
136132}
137- export const selectLink = function ( targetElement ) {
133+ export const selectLink = function ( targetElement ) {
138134 this . currentLink = targetElement
139135 const obj = targetElement . linkObj
140136 const from = obj . from
@@ -168,20 +164,12 @@ export const selectLink = function(targetElement) {
168164
169165 this . showLinkController ( p2x , p2y , p3x , p3y , obj , fromData , toData )
170166}
171- export const hideLinkController = function ( ) {
167+ export const hideLinkController = function ( ) {
172168 this . linkController . style . display = 'none'
173169 this . P2 . style . display = 'none'
174170 this . P3 . style . display = 'none'
175171}
176- export const showLinkController = function (
177- p2x ,
178- p2y ,
179- p3x ,
180- p3y ,
181- linkObj ,
182- fromData ,
183- toData
184- ) {
172+ export const showLinkController = function ( p2x , p2y , p3x , p3y , linkObj , fromData , toData ) {
185173 this . linkController . style . display = 'initial'
186174 this . P2 . style . display = 'initial'
187175 this . P3 . style . display = 'initial'
@@ -227,10 +215,7 @@ export const showLinkController = function(
227215
228216 this . P2 . style . top = p2y + 'px'
229217 this . P2 . style . left = p2x + 'px'
230- this . currentLink . children [ 0 ] . setAttribute (
231- 'd' ,
232- `M ${ p1x } ${ p1y } C ${ p2x } ${ p2y } ${ p3x } ${ p3y } ${ p4x } ${ p4y } `
233- )
218+ this . currentLink . children [ 0 ] . setAttribute ( 'd' , `M ${ p1x } ${ p1y } C ${ p2x } ${ p2y } ${ p3x } ${ p3y } ${ p4x } ${ p4y } ` )
234219 this . line1 . setAttribute ( 'x1' , p1x )
235220 this . line1 . setAttribute ( 'y1' , p1y )
236221 this . line1 . setAttribute ( 'x2' , p2x )
@@ -250,14 +235,8 @@ export const showLinkController = function(
250235
251236 this . P3 . style . top = p3y + 'px'
252237 this . P3 . style . left = p3x + 'px'
253- this . currentLink . children [ 0 ] . setAttribute (
254- 'd' ,
255- `M ${ p1x } ${ p1y } C ${ p2x } ${ p2y } ${ p3x } ${ p3y } ${ p4x } ${ p4y } `
256- )
257- this . currentLink . children [ 1 ] . setAttribute (
258- 'd' ,
259- `M ${ arrowPoint . x1 } ${ arrowPoint . y1 } L ${ p4x } ${ p4y } L ${ arrowPoint . x2 } ${ arrowPoint . y2 } `
260- )
238+ this . currentLink . children [ 0 ] . setAttribute ( 'd' , `M ${ p1x } ${ p1y } C ${ p2x } ${ p2y } ${ p3x } ${ p3y } ${ p4x } ${ p4y } ` )
239+ this . currentLink . children [ 1 ] . setAttribute ( 'd' , `M ${ arrowPoint . x1 } ${ arrowPoint . y1 } L ${ p4x } ${ p4y } L ${ arrowPoint . x2 } ${ arrowPoint . y2 } ` )
261240 this . line2 . setAttribute ( 'x1' , p3x )
262241 this . line2 . setAttribute ( 'y1' , p3y )
263242 this . line2 . setAttribute ( 'x2' , p4x )
0 commit comments