@@ -107,8 +107,35 @@ class Link {
107107 let dx = e . detail . p . x - x ;
108108 x = e . detail . p . x ;
109109 draggedHandle . offset += dx ;
110+ let anchor = draggedHandle . anchor ;
111+ if ( anchor instanceof Link ) {
112+ if ( anchor . trigger ) {
113+ if ( anchor . trigger . idx > anchor . endpoints [ 0 ] . idx ) {
114+ console . log ( 'hey' ) ;
115+ }
116+ }
117+
118+ // let l = draggedHandle.anchor;
119+ // let boundaries = l.handles
120+ // // .filter(h => !l.trigger || h.anchor.row === l.trigger.row)
121+ // .map(h => h.x);
122+ // if (l.trigger) { console.log(l.trigger.row); }
123+ // console.log(boundaries);
124+ // // console.log(draggedHandle.anchor.cx, draggedHandle.anchor.endpoints);
125+ }
126+ else {
127+ let halfWidth = anchor . boxWidth / 2 ;
128+ if ( this . top && anchor . tag instanceof WordTag ) {
129+ halfWidth = anchor . tag . ww / 2 ;
130+ }
131+ else if ( ! this . top && anchor . syntaxTag instanceof WordTag ) {
132+ halfWidth = anchor . syntaxTag . ww / 2 ;
133+ }
134+ draggedHandle . offset = draggedHandle . offset < 0
135+ ? Math . max ( - halfWidth + 3 , draggedHandle . offset )
136+ : Math . min ( halfWidth - 3 , draggedHandle . offset ) ;
137+ }
110138 this . draw ( draggedHandle . anchor ) ;
111- // console.log(dx, x, draggedHandle );
112139 }
113140 } )
114141 . on ( 'dragend' , ( ) => { draggedHandle = null } ) ;
@@ -230,11 +257,18 @@ class Link {
230257
231258 if ( handlePrecedesTrigger ) {
232259 // draw trigger to the right of the arrow segment
233- d += 'L' + [ this . handles [ 0 ] . x - dx , y ]
234- + 'c' + [ dx , 0 , dx , 0 , dx , this . handles [ 0 ] . y - y ] ;
235260 if ( i + 1 < il ) {
261+ d += 'L' + [ this . handles [ 0 ] . x - dx , y ]
262+ + 'c' + [ dx , 0 , dx , 0 , dx , this . handles [ 0 ] . y - y ]
263+ + 'm' + [ dx , 0 ]
264+ + 'l' + [ - 2 * dx , 0 ]
265+ + 'm' + [ dx , 0 ]
266+ + 'C' + [ this . handles [ 0 ] . x , y , this . handles [ 0 ] . x , y , this . handles [ 0 ] . x + dx , y ] ;
236267 rowCrossed = this . handles [ i + 2 ] . anchor . row . idx != this . handles [ 0 ] . anchor . row . idx ;
237- d += 'C' + [ this . handles [ 0 ] . x , y , this . handles [ 0 ] . x , y , this . handles [ 0 ] . x + dx , y ] ;
268+ }
269+ else {
270+ d += 'L' + [ this . handles [ 0 ] . x - dx , y ]
271+ + 'c' + [ dx , 0 , dx , 0 , dx , this . handles [ 0 ] . y - y ] ;
238272 }
239273 }
240274 }
@@ -409,6 +443,14 @@ class Link {
409443 }
410444
411445 get cx ( ) {
446+ if ( this . line ) {
447+ if ( this . trigger ) {
448+ return this . trigger . cx + this . handles [ 0 ] . offset ;
449+ }
450+ else {
451+ // FIXME: does not occur currently
452+ }
453+ }
412454 return this . rootWord . cx ;
413455 }
414456
0 commit comments