( script: string, animationId: string, index: number, )
| 2995 | * out-of-range index, cubic paths, or a 2-point path. |
| 2996 | */ |
| 2997 | export function removeMotionPathPointInScript( |
| 2998 | script: string, |
| 2999 | animationId: string, |
| 3000 | index: number, |
| 3001 | ): string { |
| 3002 | const loc = locateAnimation(script, animationId); |
| 3003 | if (!loc) return script; |
| 3004 | const anim = loc.target.animation; |
| 3005 | if (!anim.arcPath?.enabled || hasCubicSegments(anim.arcPath.segments)) return script; |
| 3006 | |
| 3007 | const waypoints = extractArcWaypoints(anim); |
| 3008 | if (waypoints.length <= 2 || index < 0 || index >= waypoints.length) return script; |
| 3009 | |
| 3010 | const segments = [...anim.arcPath.segments]; |
| 3011 | waypoints.splice(index, 1); |
| 3012 | // Drop the segment on the side that still exists (last anchor → preceding segment). |
| 3013 | segments.splice(Math.min(index, segments.length - 1), 1); |
| 3014 | |
| 3015 | return writeMotionPathValue(loc, waypoints, segments, anim.arcPath.autoRotate); |
| 3016 | } |
| 3017 | |
| 3018 | /** |
| 3019 | * Author a fresh 2-anchor motionPath tween on a target element: a straight line |
no test coverage detected