您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

translate-command.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. }