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.

translate.ts 782B

1234567891011121314151617181920212223242526272829303132
  1. import Command from "./command"
  2. import history from "../history"
  3. import { TranslateSnapshot } from "state/sessions/translate-session"
  4. import { Data } from "types"
  5. export default function translateCommand(
  6. data: Data,
  7. before: TranslateSnapshot,
  8. after: TranslateSnapshot
  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 } of after.shapes) {
  18. shapes[id].point = point
  19. }
  20. },
  21. undo(data) {
  22. const { shapes } = data.document.pages[before.currentPageId]
  23. for (let { id, point } of before.shapes) {
  24. shapes[id].point = point
  25. }
  26. },
  27. })
  28. )
  29. }