diff --git a/packages/excalidraw/actions/actionLinearEditor.tsx b/packages/excalidraw/actions/actionLinearEditor.tsx
index 0aa4d033f..a62a88cb3 100644
--- a/packages/excalidraw/actions/actionLinearEditor.tsx
+++ b/packages/excalidraw/actions/actionLinearEditor.tsx
@@ -94,6 +94,38 @@ export const actionToggleLinearEditor = register({
},
});
+const updateLoopLock = (
+ element: ExcalidrawLineElement,
+ newLoopLockState: boolean,
+ app: any,
+) => {
+ const updatedPoints = [...element.points];
+
+ if (newLoopLockState) {
+ const firstPoint = updatedPoints[0];
+ const lastPoint = updatedPoints[updatedPoints.length - 1];
+
+ const distance = Math.hypot(
+ firstPoint[0] - lastPoint[0],
+ firstPoint[1] - lastPoint[1],
+ );
+
+ if (distance > MIN_LOOP_LOCK_DISTANCE) {
+ updatedPoints.push(pointFrom(firstPoint[0], firstPoint[1]));
+ } else {
+ updatedPoints[updatedPoints.length - 1] = pointFrom(
+ firstPoint[0],
+ firstPoint[1],
+ );
+ }
+ }
+
+ app.scene.mutateElement(element, {
+ loopLock: newLoopLockState,
+ points: updatedPoints,
+ });
+};
+
export const actionToggleLoopLock = register({
name: "toggleLoopLock",
category: DEFAULT_CATEGORIES.elements,
@@ -143,31 +175,7 @@ export const actionToggleLoopLock = register({
const newLoopLockState = !allLocked;
selectedElements.forEach((element) => {
- const updatedPoints = [...element.points];
-
- if (newLoopLockState) {
- const firstPoint = updatedPoints[0];
- const lastPoint = updatedPoints[updatedPoints.length - 1];
-
- const distance = Math.hypot(
- firstPoint[0] - lastPoint[0],
- firstPoint[1] - lastPoint[1],
- );
-
- if (distance > MIN_LOOP_LOCK_DISTANCE) {
- updatedPoints.push(pointFrom(firstPoint[0], firstPoint[1]));
- } else {
- updatedPoints[updatedPoints.length - 1] = pointFrom(
- firstPoint[0],
- firstPoint[1],
- );
- }
- }
-
- app.scene.mutateElement(element, {
- loopLock: newLoopLockState,
- points: updatedPoints,
- });
+ updateLoopLock(element, newLoopLockState, app);
});
return {
diff --git a/packages/excalidraw/components/icons.tsx b/packages/excalidraw/components/icons.tsx
index 02e6b6077..18e7ce8b9 100644
--- a/packages/excalidraw/components/icons.tsx
+++ b/packages/excalidraw/components/icons.tsx
@@ -132,21 +132,9 @@ export const PinIcon = createIcon(
export const LoopLockedIcon = createIcon(
-
,
@@ -156,21 +144,9 @@ export const LoopLockedIcon = createIcon(
export const LoopUnlockedIcon = createIcon(
-
,