Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

transform.ts 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Command from "./command"
  2. import history from "../history"
  3. import { Data, Corner, Edge } from "types"
  4. import { TransformSnapshot } from "state/sessions/transform-session"
  5. import { getShapeUtils } from "lib/shape-utils"
  6. import { getPage } from "utils/utils"
  7. export default function transformCommand(
  8. data: Data,
  9. before: TransformSnapshot,
  10. after: TransformSnapshot,
  11. scaleX: number,
  12. scaleY: number
  13. ) {
  14. history.execute(
  15. data,
  16. new Command({
  17. name: "translate_shapes",
  18. category: "canvas",
  19. do(data) {
  20. const { type, selectedIds } = after
  21. const { shapes } = getPage(data)
  22. selectedIds.forEach((id) => {
  23. const { initialShape, initialShapeBounds, transformOrigin } =
  24. after.shapeBounds[id]
  25. const shape = shapes[id]
  26. getShapeUtils(shape).transform(shape, initialShapeBounds, {
  27. type,
  28. initialShape,
  29. scaleX: 1,
  30. scaleY: 1,
  31. transformOrigin,
  32. })
  33. })
  34. },
  35. undo(data) {
  36. const { type, selectedIds } = before
  37. const { shapes } = getPage(data)
  38. selectedIds.forEach((id) => {
  39. const { initialShape, initialShapeBounds, transformOrigin } =
  40. before.shapeBounds[id]
  41. const shape = shapes[id]
  42. getShapeUtils(shape).transform(shape, initialShapeBounds, {
  43. type,
  44. initialShape,
  45. scaleX: 1,
  46. scaleY: 1,
  47. transformOrigin,
  48. })
  49. })
  50. },
  51. })
  52. )
  53. }