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.

transform.ts 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import { TransformSnapshot } from 'state/sessions/transform-session'
  5. import { getShapeUtils } from 'lib/shape-utils'
  6. import { getPage, updateParents } 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: 'transform_shapes',
  18. category: 'canvas',
  19. do(data) {
  20. const { shapeBounds } = after
  21. const { shapes } = getPage(data)
  22. for (let id in shapeBounds) {
  23. shapes[id] = shapeBounds[id].initialShape
  24. }
  25. updateParents(data, Object.keys(shapeBounds))
  26. },
  27. undo(data) {
  28. const { shapeBounds } = before
  29. const { shapes } = getPage(data)
  30. for (let id in shapeBounds) {
  31. shapes[id] = shapeBounds[id].initialShape
  32. }
  33. updateParents(data, Object.keys(shapeBounds))
  34. },
  35. })
  36. )
  37. }