You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rotate.ts 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Command from "./command"
  2. import history from "../history"
  3. import { Data } from "types"
  4. import { RotateSnapshot } from "state/sessions/rotate-session"
  5. export default function translateCommand(
  6. data: Data,
  7. before: RotateSnapshot,
  8. after: RotateSnapshot
  9. ) {
  10. history.execute(
  11. data,
  12. new Command({
  13. name: "translate_shapes",
  14. category: "canvas",
  15. do(data) {
  16. const { shapes } = data.document.pages[after.currentPageId]
  17. for (let { id, point, rotation } of after.shapes) {
  18. const shape = shapes[id]
  19. shape.rotation = rotation
  20. shape.point = point
  21. }
  22. data.boundsRotation = after.boundsRotation
  23. },
  24. undo(data) {
  25. const { shapes } = data.document.pages[before.currentPageId]
  26. for (let { id, point, rotation } of before.shapes) {
  27. const shape = shapes[id]
  28. shape.rotation = rotation
  29. shape.point = point
  30. }
  31. data.boundsRotation = before.boundsRotation
  32. },
  33. })
  34. )
  35. }