use deltas in transforms
This commit is contained in:
parent
e2805ab6d2
commit
b45cef260a
2 changed files with 17 additions and 30 deletions
|
@ -43,16 +43,12 @@ export default class TransformSession extends BaseSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data: Data, point: number[]) {
|
update(data: Data, point: number[]) {
|
||||||
const {
|
const { shapeBounds, initialBounds, currentPageId, selectedIds } =
|
||||||
shapeBounds,
|
this.snapshot
|
||||||
initialBounds,
|
|
||||||
currentPageId,
|
|
||||||
selectedIds,
|
|
||||||
} = this.snapshot
|
|
||||||
|
|
||||||
const { shapes } = data.document.pages[currentPageId]
|
const { shapes } = data.document.pages[currentPageId]
|
||||||
|
|
||||||
let [x, y] = point
|
const delta = vec.vec(this.origin, point)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
corners: { a, b },
|
corners: { a, b },
|
||||||
|
@ -63,39 +59,39 @@ export default class TransformSession extends BaseSession {
|
||||||
|
|
||||||
switch (transformType) {
|
switch (transformType) {
|
||||||
case TransformEdge.Top: {
|
case TransformEdge.Top: {
|
||||||
a[1] = y
|
a[1] = initialBounds.minY + delta[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformEdge.Right: {
|
case TransformEdge.Right: {
|
||||||
b[0] = x
|
b[0] = initialBounds.maxX + delta[0]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformEdge.Bottom: {
|
case TransformEdge.Bottom: {
|
||||||
b[1] = y
|
b[1] = initialBounds.maxY + delta[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformEdge.Left: {
|
case TransformEdge.Left: {
|
||||||
a[0] = x
|
a[0] = initialBounds.minX + delta[0]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformCorner.TopLeft: {
|
case TransformCorner.TopLeft: {
|
||||||
a[1] = y
|
a[0] = initialBounds.minX + delta[0]
|
||||||
a[0] = x
|
a[1] = initialBounds.minY + delta[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformCorner.TopRight: {
|
case TransformCorner.TopRight: {
|
||||||
b[0] = x
|
a[1] = initialBounds.minY + delta[1]
|
||||||
a[1] = y
|
b[0] = initialBounds.maxX + delta[0]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformCorner.BottomRight: {
|
case TransformCorner.BottomRight: {
|
||||||
b[1] = y
|
b[0] = initialBounds.maxX + delta[0]
|
||||||
b[0] = x
|
b[1] = initialBounds.maxY + delta[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case TransformCorner.BottomLeft: {
|
case TransformCorner.BottomLeft: {
|
||||||
a[0] = x
|
a[0] = initialBounds.minX + delta[0]
|
||||||
b[1] = y
|
b[1] = initialBounds.maxY + delta[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,12 +156,8 @@ export default class TransformSession extends BaseSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(data: Data) {
|
cancel(data: Data) {
|
||||||
const {
|
const { shapeBounds, initialBounds, currentPageId, selectedIds } =
|
||||||
shapeBounds,
|
this.snapshot
|
||||||
initialBounds,
|
|
||||||
currentPageId,
|
|
||||||
selectedIds,
|
|
||||||
} = this.snapshot
|
|
||||||
|
|
||||||
const { shapes } = data.document.pages[currentPageId]
|
const { shapes } = data.document.pages[currentPageId]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1 @@
|
||||||
@import url("https://fonts.googleapis.com/css2?family=Recursive:wght@500;700&display=swap");
|
@import url("https://fonts.googleapis.com/css2?family=Recursive:wght@500;700&display=swap");
|
||||||
|
|
||||||
:root {
|
|
||||||
--camera-zoom: 1;
|
|
||||||
--scale: calc(1 / var(--camera-zoom));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue