Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

handle.ts 966B

123456789101112131415161718192021222324252627282930313233343536
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import { getPage } from 'utils/utils'
  5. import { HandleSnapshot } from 'state/sessions/handle-session'
  6. import { getShapeUtils } from 'lib/shape-utils'
  7. export default function handleCommand(
  8. data: Data,
  9. before: HandleSnapshot,
  10. after: HandleSnapshot
  11. ) {
  12. history.execute(
  13. data,
  14. new Command({
  15. name: 'moved_handle',
  16. category: 'canvas',
  17. do(data, isInitial) {
  18. if (isInitial) return
  19. const { initialShape, currentPageId } = after
  20. const shape = getPage(data, currentPageId).shapes[initialShape.id]
  21. getShapeUtils(shape).onHandleMove(shape, initialShape.handles)
  22. },
  23. undo(data) {
  24. const { initialShape, currentPageId } = before
  25. const shape = getPage(data, currentPageId).shapes[initialShape.id]
  26. getShapeUtils(shape).onHandleMove(shape, initialShape.handles)
  27. },
  28. })
  29. )
  30. }