From f6041b57400810061ac73d2b2089694363b80ece Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Sun, 25 Jul 2021 14:18:57 +0200 Subject: [PATCH] minor ES6 improvements --- src/editor/EditorStartup.js | 4 +--- src/svgcanvas/selected-elem.js | 23 ++++------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/editor/EditorStartup.js b/src/editor/EditorStartup.js index f2b66ade..ac454b73 100644 --- a/src/editor/EditorStartup.js +++ b/src/editor/EditorStartup.js @@ -61,16 +61,14 @@ class EditorStartup { * @returns {void} */ async init () { - if ('localStorage' in window) { // && onWeb removed so Webkit works locally + if ('localStorage' in window) { this.storage = window.localStorage; } this.configObj.load(); const self = this; const { i18next } = await putLocale(this.configObj.pref('lang'), this.goodLangs); this.i18next = i18next; - // eslint-disable-next-line no-unsanitized/method await import(`./components/index.js`); - // eslint-disable-next-line no-unsanitized/method await import(`./dialogs/index.js`); // allow to prepare the dom without display this.$svgEditor.style.visibility = 'hidden'; diff --git a/src/svgcanvas/selected-elem.js b/src/svgcanvas/selected-elem.js index 9b5014dd..00cecd9f 100644 --- a/src/svgcanvas/selected-elem.js +++ b/src/svgcanvas/selected-elem.js @@ -155,43 +155,28 @@ export const moveUpDownSelected = function (dir) { * @returns {BatchCommand|void} Batch command for the move */ -export const moveSelectedElements = function (dx, dy, undoable) { +export const moveSelectedElements = function (dx, dy, undoable = true) { const selectedElements = elementContext_.getSelectedElements(); const currentZoom = elementContext_.getCurrentZoom(); // if undoable is not sent, default to true // if single values, scale them to the zoom - if (dx.constructor !== Array) { + if (!Array.isArray(dx)) { dx /= currentZoom; dy /= currentZoom; } - undoable = undoable || true; + const batchCmd = new BatchCommand('position'); let i = selectedElements.length; while (i--) { const selected = selectedElements[i]; if (!isNullish(selected)) { - // if (i === 0) { - // selectedBBoxes[0] = utilsGetBBox(selected); - // } - // const b = {}; - // for (const j in selectedBBoxes[i]) b[j] = selectedBBoxes[i][j]; - // selectedBBoxes[i] = b; - const xform = elementContext_.getSVGRoot().createSVGTransform(); const tlist = getTransformList(selected); // dx and dy could be arrays - if (dx.constructor === Array) { - // if (i === 0) { - // selectedBBoxes[0].x += dx[0]; - // selectedBBoxes[0].y += dy[0]; - // } + if (Array.isArray(dx)) { xform.setTranslate(dx[i], dy[i]); } else { - // if (i === 0) { - // selectedBBoxes[0].x += dx; - // selectedBBoxes[0].y += dy; - // } xform.setTranslate(dx, dy); }