Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

rotate.ts 1.2KB

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