File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 505505 return { x: endPoint .x , y: endPoint .y , angle };
506506 }
507507
508- // Fallback (smoothstep): arrow based on target position, use unadjusted target
509- let angle = 0 ;
510- if (targetPosition === ' left' ) angle = 180 ;
511- else if (targetPosition === ' top' ) angle = - 90 ;
512- else if (targetPosition === ' bottom' ) angle = 90 ;
508+ // Fallback (smoothstep): derive arrow position and angle from SVG path geometry
509+ const { path } = pathInfo ();
510+ if (path ) {
511+ const svgPath = document .createElementNS (' http://www.w3.org/2000/svg' , ' path' );
512+ svgPath .setAttribute (' d' , path );
513+ const totalLength = svgPath .getTotalLength ();
514+ const endPoint = svgPath .getPointAtLength (totalLength );
515+ const nearEnd = svgPath .getPointAtLength (totalLength - 5 );
516+ const angle = Math .atan2 (endPoint .y - nearEnd .y , endPoint .x - nearEnd .x ) * (180 / Math .PI );
517+ return { x: endPoint .x , y: endPoint .y , angle };
518+ }
513519
514- return { x: targetX , y: targetY , angle };
520+ return { x: tgt . x , y: tgt . y , angle: 0 };
515521 });
516522 </script >
517523
You can’t perform that action at this time.
0 commit comments