Stubs alignment distribution stretch
This commit is contained in:
parent
733acfaf3a
commit
ab50d76e6e
13 changed files with 339 additions and 56 deletions
38
state/commands/stretch.ts
Normal file
38
state/commands/stretch.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import Command from "./command"
|
||||
import history from "../history"
|
||||
import { StretchType, Data } from "types"
|
||||
import { getPage } from "utils/utils"
|
||||
import { getShapeUtils } from "lib/shape-utils"
|
||||
|
||||
export default function stretchCommand(data: Data, type: StretchType) {
|
||||
const { currentPageId } = data
|
||||
|
||||
const initialPoints = Object.fromEntries(
|
||||
Object.entries(getPage(data).shapes).map(([id, shape]) => [id, shape.point])
|
||||
)
|
||||
|
||||
history.execute(
|
||||
data,
|
||||
new Command({
|
||||
name: "distributed",
|
||||
category: "canvas",
|
||||
do(data) {
|
||||
const { shapes } = getPage(data, currentPageId)
|
||||
|
||||
switch (type) {
|
||||
case StretchType.Horizontal: {
|
||||
}
|
||||
case StretchType.Vertical: {
|
||||
}
|
||||
}
|
||||
},
|
||||
undo(data) {
|
||||
const { shapes } = getPage(data, currentPageId)
|
||||
for (let id in initialPoints) {
|
||||
const shape = shapes[id]
|
||||
getShapeUtils(shape).translateTo(shape, initialPoints[id])
|
||||
}
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue