fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
18 lines (17 loc) • 806 B
JavaScript
//#region src/controls/wrapWithFixedAnchor.ts
/**
* Wrap an action handler with saving/restoring object position on the transform.
* this is the code that permits to objects to keep their position while transforming.
* @param {Function} actionHandler the function to wrap
* @return {Function} a function with an action handler signature
*/
function wrapWithFixedAnchor(actionHandler) {
return ((eventData, transform, x, y) => {
const { target, originX, originY } = transform, constraint = target.getPositionByOrigin(originX, originY), actionPerformed = actionHandler(eventData, transform, x, y);
target.setPositionByOrigin(constraint, transform.originX, transform.originY);
return actionPerformed;
});
}
//#endregion
export { wrapWithFixedAnchor };
//# sourceMappingURL=wrapWithFixedAnchor.mjs.map