minor ES6 improvements

This commit is contained in:
JFH
2021-07-25 14:18:57 +02:00
parent a454a6342d
commit f6041b5740
2 changed files with 5 additions and 22 deletions

View File

@@ -61,16 +61,14 @@ class EditorStartup {
* @returns {void} * @returns {void}
*/ */
async init () { async init () {
if ('localStorage' in window) { // && onWeb removed so Webkit works locally if ('localStorage' in window) {
this.storage = window.localStorage; this.storage = window.localStorage;
} }
this.configObj.load(); this.configObj.load();
const self = this; const self = this;
const { i18next } = await putLocale(this.configObj.pref('lang'), this.goodLangs); const { i18next } = await putLocale(this.configObj.pref('lang'), this.goodLangs);
this.i18next = i18next; this.i18next = i18next;
// eslint-disable-next-line no-unsanitized/method
await import(`./components/index.js`); await import(`./components/index.js`);
// eslint-disable-next-line no-unsanitized/method
await import(`./dialogs/index.js`); await import(`./dialogs/index.js`);
// allow to prepare the dom without display // allow to prepare the dom without display
this.$svgEditor.style.visibility = 'hidden'; this.$svgEditor.style.visibility = 'hidden';

View File

@@ -155,43 +155,28 @@ export const moveUpDownSelected = function (dir) {
* @returns {BatchCommand|void} Batch command for the move * @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 selectedElements = elementContext_.getSelectedElements();
const currentZoom = elementContext_.getCurrentZoom(); const currentZoom = elementContext_.getCurrentZoom();
// if undoable is not sent, default to true // if undoable is not sent, default to true
// if single values, scale them to the zoom // if single values, scale them to the zoom
if (dx.constructor !== Array) { if (!Array.isArray(dx)) {
dx /= currentZoom; dx /= currentZoom;
dy /= currentZoom; dy /= currentZoom;
} }
undoable = undoable || true;
const batchCmd = new BatchCommand('position'); const batchCmd = new BatchCommand('position');
let i = selectedElements.length; let i = selectedElements.length;
while (i--) { while (i--) {
const selected = selectedElements[i]; const selected = selectedElements[i];
if (!isNullish(selected)) { 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 xform = elementContext_.getSVGRoot().createSVGTransform();
const tlist = getTransformList(selected); const tlist = getTransformList(selected);
// dx and dy could be arrays // dx and dy could be arrays
if (dx.constructor === Array) { if (Array.isArray(dx)) {
// if (i === 0) {
// selectedBBoxes[0].x += dx[0];
// selectedBBoxes[0].y += dy[0];
// }
xform.setTranslate(dx[i], dy[i]); xform.setTranslate(dx[i], dy[i]);
} else { } else {
// if (i === 0) {
// selectedBBoxes[0].x += dx;
// selectedBBoxes[0].y += dy;
// }
xform.setTranslate(dx, dy); xform.setTranslate(dx, dy);
} }