0b80ca798a7f39bf2839d07d52102c5b.json
5.05 KB
{"ast":null,"code":"/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Rotate an image\r\n */\nimport commandFactory from '../factory/command';\nimport { componentNames, commandNames } from '../consts';\nconst {\n ROTATION\n} = componentNames;\n/**\r\n * Chched data for undo\r\n * @type {Object}\r\n */\n\nlet chchedUndoDataForSilent = null;\n/**\r\n * Make undo data\r\n * @param {Component} rotationComp - rotation component\r\n * @returns {object} - undodata\r\n */\n\nfunction makeUndoData(rotationComp) {\n return {\n angle: rotationComp.getCurrentAngle()\n };\n}\n\nconst command = {\n name: commandNames.ROTATE_IMAGE,\n\n /**\r\n * Rotate an image\r\n * @param {Graphics} graphics - Graphics instance\r\n * @param {string} type - 'rotate' or 'setAngle'\r\n * @param {number} angle - angle value (degree)\r\n * @param {boolean} isSilent - is silent execution or not\r\n * @returns {Promise}\r\n */\n execute(graphics, type, angle, isSilent) {\n const rotationComp = graphics.getComponent(ROTATION);\n\n if (!this.isRedo) {\n const undoData = makeUndoData(rotationComp);\n chchedUndoDataForSilent = this.setUndoData(undoData, chchedUndoDataForSilent, isSilent);\n }\n\n return rotationComp[type](angle);\n },\n\n /**\r\n * @param {Graphics} graphics - Graphics instance\r\n * @returns {Promise}\r\n */\n undo(graphics) {\n const rotationComp = graphics.getComponent(ROTATION);\n const [, type, angle] = this.args;\n\n if (type === 'setAngle') {\n return rotationComp[type](this.undoData.angle);\n }\n\n return rotationComp.rotate(-angle);\n }\n\n};\ncommandFactory.register(command);\nexport default command;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/command/rotate.js"],"names":["commandFactory","componentNames","commandNames","ROTATION","chchedUndoDataForSilent","makeUndoData","rotationComp","angle","getCurrentAngle","command","name","ROTATE_IMAGE","execute","graphics","type","isSilent","getComponent","isRedo","undoData","setUndoData","undo","args","rotate","register"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAOA,cAAP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CAACuB,QAAf,CAAwBd,OAAxB;AAEA,eAAeA,OAAf","sourcesContent":["/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Rotate an image\r\n */\r\nimport commandFactory from '../factory/command';\r\nimport { componentNames, commandNames } from '../consts';\r\n\r\nconst { ROTATION } = componentNames;\r\n\r\n/**\r\n * Chched data for undo\r\n * @type {Object}\r\n */\r\nlet chchedUndoDataForSilent = null;\r\n\r\n/**\r\n * Make undo data\r\n * @param {Component} rotationComp - rotation component\r\n * @returns {object} - undodata\r\n */\r\nfunction makeUndoData(rotationComp) {\r\n return {\r\n angle: rotationComp.getCurrentAngle(),\r\n };\r\n}\r\n\r\nconst command = {\r\n name: commandNames.ROTATE_IMAGE,\r\n\r\n /**\r\n * Rotate an image\r\n * @param {Graphics} graphics - Graphics instance\r\n * @param {string} type - 'rotate' or 'setAngle'\r\n * @param {number} angle - angle value (degree)\r\n * @param {boolean} isSilent - is silent execution or not\r\n * @returns {Promise}\r\n */\r\n execute(graphics, type, angle, isSilent) {\r\n const rotationComp = graphics.getComponent(ROTATION);\r\n\r\n if (!this.isRedo) {\r\n const undoData = makeUndoData(rotationComp);\r\n\r\n chchedUndoDataForSilent = this.setUndoData(undoData, chchedUndoDataForSilent, isSilent);\r\n }\r\n\r\n return rotationComp[type](angle);\r\n },\r\n /**\r\n * @param {Graphics} graphics - Graphics instance\r\n * @returns {Promise}\r\n */\r\n undo(graphics) {\r\n const rotationComp = graphics.getComponent(ROTATION);\r\n const [, type, angle] = this.args;\r\n\r\n if (type === 'setAngle') {\r\n return rotationComp[type](this.undoData.angle);\r\n }\r\n\r\n return rotationComp.rotate(-angle);\r\n },\r\n};\r\n\r\ncommandFactory.register(command);\r\n\r\nexport default command;\r\n"]},"metadata":{},"sourceType":"module"}