Skip to content

Commit

Permalink
fix: fix roundable line index #756
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Oct 10, 2022
1 parent 99da903 commit 83d5232
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/react-moveable/src/react-moveable/ables/Roundable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,17 @@ export default {
const isControl = className.indexOf("border-radius") > -1;
const isLine = className.indexOf("moveable-line") > -1 && className.indexOf("moveable-direction") > -1;
const controlIndex = isControl ? parseInt(inputTarget.getAttribute("data-radius-index"), 10) : -1;
const lineIndex = isLine ? parseInt(inputTarget.getAttribute("data-line-index"), 10) : -1;
let lineIndex = -1;

if (isLine) {
const indexAttr = inputTarget.getAttribute("data-line-index")!;

lineIndex = parseInt(indexAttr.replace(/render-line-/g, ""), 10);

if (isNaN(lineIndex)) {
lineIndex = -1;
}
}

if (!isControl && !isLine) {
return false;
Expand Down Expand Up @@ -377,6 +387,7 @@ export default {

addBorderRadius(controlPoses, poses, lineIndex, distX, distY, width, height);
}

if (length !== controlPoses.length) {
triggerRoundEvent(
moveable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function renderLine(
return <div key={`line-${key}`}
className={prefix("line", "direction", direction ? "edge" : "", direction, ...classNames)}
data-rotation={rotation}
data-line-index={key}
data-line-key={key}
data-direction={direction} style={getLineStyle(pos1, pos2, zoom, rad)}></div>;
}

Expand Down

0 comments on commit 83d5232

Please sign in to comment.