グループの子要素の位置を再帰的に更新
code:ts
// 位置の変更差分を子供全てに適用する
const updatePosition = <T extends StateItem>(item: T, diff: paper.Point): T => {
const newPosition = item.position.add(diff);
if (isGroupStateItem(item)) {
const newChildren = item.items.map((x) => (updatePosition(x, diff)))
return {
...item,
position: newPosition,
nameplate: updatePosition(item.nameplate, diff),
items: newChildren,
}
} else {
return {
...item, position: newPosition
}
}
}