{"version":3,"file":"drag.mjs","names":[],"sources":["../../../src/controls/drag.ts"],"sourcesContent":["import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n  eventData,\n  transform,\n  x,\n  y,\n) => {\n  const { target, offsetX, offsetY } = transform,\n    newLeft = x - offsetX,\n    newTop = y - offsetY,\n    moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n    moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n  moveX && target.set(LEFT, newLeft);\n  moveY && target.set(TOP, newTop);\n  if (moveX || moveY) {\n    fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n  }\n  return moveX || moveY;\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,eACX,WACA,WACA,GACA,MACG;CACH,MAAM,EAAE,QAAQ,SAAS,YAAY,WACnC,UAAU,IAAI,SACd,SAAS,IAAI,SACb,QAAQ,CAAC,SAAS,QAAQ,gBAAgB,IAAI,OAAO,SAAS,SAC9D,QAAQ,CAAC,SAAS,QAAQ,gBAAgB,IAAI,OAAO,QAAQ;AAC/D,UAAS,OAAO,IAAA,QAAU,QAAQ;AAClC,UAAS,OAAO,IAAA,OAAS,OAAO;AAChC,KAAI,SAAS,MACX,WAAU,QAAQ,gBAAgB,WAAW,WAAW,GAAG,EAAE,CAAC;AAEhE,QAAO,SAAS"}