- Fix: Centering of canvas wasn't being set at proper time; fixes #272

- Refactoring: Avoid unneeded internal IIFEs; simplify w/h formula
master
Brett Zamir 2018-10-21 01:13:44 +08:00
parent 5d9da2d56e
commit c37e60fd87
12 changed files with 179 additions and 214 deletions

View File

@ -12,6 +12,7 @@
- Fix: Allow language to be properly set back to a different locale and - Fix: Allow language to be properly set back to a different locale and
retaining preference (and ensure language changes are available before retaining preference (and ensure language changes are available before
dialog closed) dialog closed)
- Fix: Centering of canvas wasn't being set at proper time; fixes #272
- Fix (regression): Extension locale loading for non-English locales - Fix (regression): Extension locale loading for non-English locales
- Enhancement: Allow "Escape" to work with hotkeys within text boxes; - Enhancement: Allow "Escape" to work with hotkeys within text boxes;
allows escaping out of source textarea (part of #291) allows escaping out of source textarea (part of #291)
@ -20,6 +21,7 @@
- Enhancement: Add a global escape key listener to clear the selection - Enhancement: Add a global escape key listener to clear the selection
- Refactoring: Change 'a' to lower case in key command to avoid impression - Refactoring: Change 'a' to lower case in key command to avoid impression
that shift is needed that shift is needed
- Refactoring: Avoid unneeded internal IIFEs; simplify w/h formula
- Refactoring: array extra/spread operator - Refactoring: array extra/spread operator
- npm: Update devDeps - npm: Update devDeps

View File

@ -307,7 +307,7 @@ var svgEditorExtension_storage = (function () {
svgEditor.storagePromptClosed = true; svgEditor.storagePromptClosed = true;
}, null, null, { }, null, null, {
label: rememberLabel, label: rememberLabel,
checked: false, checked: true,
tooltip: rememberTooltip tooltip: rememberTooltip
}); });
} else if (!noStorageOnLoad || forceStorage) { } else if (!noStorageOnLoad || forceStorage) {

18
dist/index-es.js vendored
View File

@ -20962,8 +20962,8 @@ function SvgCanvas(container, config) {
var bg = $$9('#canvasBackground')[0]; var bg = $$9('#canvasBackground')[0];
var oldX = svgcontent.getAttribute('x'); var oldX = svgcontent.getAttribute('x');
var oldY = svgcontent.getAttribute('y'); var oldY = svgcontent.getAttribute('y');
var x = w / 2 - this.contentW * currentZoom / 2; var x = (w - this.contentW * currentZoom) / 2;
var y = h / 2 - this.contentH * currentZoom / 2; var y = (h - this.contentH * currentZoom) / 2;
assignAttributes(svgcontent, { assignAttributes(svgcontent, {
width: this.contentW * currentZoom, width: this.contentW * currentZoom,
height: this.contentH * currentZoom, height: this.contentH * currentZoom,
@ -28450,6 +28450,7 @@ editor.init = function () {
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
updateCanvas(true);
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -32441,7 +32442,6 @@ editor.init = function () {
}; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9) }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) { if (isIE()) {
(function () {
resetScrollPos = function resetScrollPos() { resetScrollPos = function resetScrollPos() {
if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) { if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
workarea[0].scrollLeft = curScrollPos.left; workarea[0].scrollLeft = curScrollPos.left;
@ -32467,7 +32467,6 @@ editor.init = function () {
top: workarea[0].scrollTop top: workarea[0].scrollTop
}; };
}); });
})();
} }
$$b(window).resize(function (evt) { $$b(window).resize(function (evt) {
@ -32478,8 +32477,6 @@ editor.init = function () {
}); });
setFlyoutPositions(); setFlyoutPositions();
}); });
(function () {
workarea.scroll(function () { workarea.scroll(function () {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($$b('#ruler_x').length) { if ($$b('#ruler_x').length) {
@ -32490,8 +32487,6 @@ editor.init = function () {
$$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop; $$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
} }
}); });
})();
$$b('#url_notice').click(function () { $$b('#url_notice').click(function () {
$$b.alert(this.title); $$b.alert(this.title);
}); });
@ -34047,14 +34042,11 @@ editor.init = function () {
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // $(function () { } // const revnums = 'svg-editor.js ($Rev$) ';
updateCanvas(true); // });
// const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

18
dist/index-umd.js vendored
View File

@ -20968,8 +20968,8 @@
var bg = $$9('#canvasBackground')[0]; var bg = $$9('#canvasBackground')[0];
var oldX = svgcontent.getAttribute('x'); var oldX = svgcontent.getAttribute('x');
var oldY = svgcontent.getAttribute('y'); var oldY = svgcontent.getAttribute('y');
var x = w / 2 - this.contentW * currentZoom / 2; var x = (w - this.contentW * currentZoom) / 2;
var y = h / 2 - this.contentH * currentZoom / 2; var y = (h - this.contentH * currentZoom) / 2;
assignAttributes(svgcontent, { assignAttributes(svgcontent, {
width: this.contentW * currentZoom, width: this.contentW * currentZoom,
height: this.contentH * currentZoom, height: this.contentH * currentZoom,
@ -28456,6 +28456,7 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
updateCanvas(true);
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -32447,7 +32448,6 @@
}; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9) }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) { if (isIE()) {
(function () {
resetScrollPos = function resetScrollPos() { resetScrollPos = function resetScrollPos() {
if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) { if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
workarea[0].scrollLeft = curScrollPos.left; workarea[0].scrollLeft = curScrollPos.left;
@ -32473,7 +32473,6 @@
top: workarea[0].scrollTop top: workarea[0].scrollTop
}; };
}); });
})();
} }
$$b(window).resize(function (evt) { $$b(window).resize(function (evt) {
@ -32484,8 +32483,6 @@
}); });
setFlyoutPositions(); setFlyoutPositions();
}); });
(function () {
workarea.scroll(function () { workarea.scroll(function () {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($$b('#ruler_x').length) { if ($$b('#ruler_x').length) {
@ -32496,8 +32493,6 @@
$$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop; $$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
} }
}); });
})();
$$b('#url_notice').click(function () { $$b('#url_notice').click(function () {
$$b.alert(this.title); $$b.alert(this.title);
}); });
@ -34053,14 +34048,11 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // $(function () { } // const revnums = 'svg-editor.js ($Rev$) ';
updateCanvas(true); // });
// const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -819,6 +819,7 @@ editor.init = function () {
$('.flyout_arrow_horiz:empty').each(function () { $('.flyout_arrow_horiz:empty').each(function () {
$(this).append($.getSvgIcon('arrow_right', true).width(5).height(5)); $(this).append($.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
updateCanvas(true);
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -2089,6 +2090,7 @@ editor.init = function () {
updateRulers(cnvs, zoom); updateRulers(cnvs, zoom);
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && !editor.storagePromptClosed) {
$('#dialog_box').hide(); $('#dialog_box').hide();
} }
@ -4504,7 +4506,6 @@ editor.init = function () {
// Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9) // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) { if (isIE()) {
(() => {
resetScrollPos = function () { resetScrollPos = function () {
if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) { if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
workarea[0].scrollLeft = curScrollPos.left; workarea[0].scrollLeft = curScrollPos.left;
@ -4532,7 +4533,6 @@ editor.init = function () {
top: workarea[0].scrollTop top: workarea[0].scrollTop
}; };
}); });
})();
} }
$(window).resize(function (evt) { $(window).resize(function (evt) {
@ -4544,7 +4544,6 @@ editor.init = function () {
setFlyoutPositions(); setFlyoutPositions();
}); });
(() => {
workarea.scroll(function () { workarea.scroll(function () {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($('#ruler_x').length) { if ($('#ruler_x').length) {
@ -4554,7 +4553,6 @@ editor.init = function () {
$('#ruler_y')[0].scrollTop = workarea[0].scrollTop; $('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
} }
}); });
})();
$('#url_notice').click(function () { $('#url_notice').click(function () {
$.alert(this.title); $.alert(this.title);
@ -5723,10 +5721,6 @@ editor.init = function () {
$('#tool_import').show().prepend(imgImport); $('#tool_import').show().prepend(imgImport);
} }
// $(function () {
updateCanvas(true);
// });
// const revnums = 'svg-editor.js ($Rev$) '; // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);

View File

@ -7005,8 +7005,8 @@ this.updateCanvas = function (w, h) {
const bg = $('#canvasBackground')[0]; const bg = $('#canvasBackground')[0];
const oldX = svgcontent.getAttribute('x'); const oldX = svgcontent.getAttribute('x');
const oldY = svgcontent.getAttribute('y'); const oldY = svgcontent.getAttribute('y');
const x = (w / 2 - this.contentW * currentZoom / 2); const x = ((w - this.contentW * currentZoom) / 2);
const y = (h / 2 - this.contentH * currentZoom / 2); const y = ((h - this.contentH * currentZoom) / 2);
assignAttributes(svgcontent, { assignAttributes(svgcontent, {
width: this.contentW * currentZoom, width: this.contentW * currentZoom,
@ -7032,6 +7032,7 @@ this.updateCanvas = function (w, h) {
} }
selectorManager.selectorParentGroup.setAttribute('transform', 'translate(' + x + ',' + y + ')'); selectorManager.selectorParentGroup.setAttribute('transform', 'translate(' + x + ',' + y + ')');
/** /**
* Invoked upon updates to the canvas. * Invoked upon updates to the canvas.
* @event module:svgcanvas.SvgCanvas#event:ext-canvasUpdated * @event module:svgcanvas.SvgCanvas#event:ext-canvasUpdated

View File

@ -20965,8 +20965,8 @@
var bg = $$9('#canvasBackground')[0]; var bg = $$9('#canvasBackground')[0];
var oldX = svgcontent.getAttribute('x'); var oldX = svgcontent.getAttribute('x');
var oldY = svgcontent.getAttribute('y'); var oldY = svgcontent.getAttribute('y');
var x = w / 2 - this.contentW * currentZoom / 2; var x = (w - this.contentW * currentZoom) / 2;
var y = h / 2 - this.contentH * currentZoom / 2; var y = (h - this.contentH * currentZoom) / 2;
assignAttributes(svgcontent, { assignAttributes(svgcontent, {
width: this.contentW * currentZoom, width: this.contentW * currentZoom,
height: this.contentH * currentZoom, height: this.contentH * currentZoom,
@ -28453,6 +28453,7 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
updateCanvas(true);
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -32444,7 +32445,6 @@
}; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9) }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) { if (isIE()) {
(function () {
resetScrollPos = function resetScrollPos() { resetScrollPos = function resetScrollPos() {
if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) { if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
workarea[0].scrollLeft = curScrollPos.left; workarea[0].scrollLeft = curScrollPos.left;
@ -32470,7 +32470,6 @@
top: workarea[0].scrollTop top: workarea[0].scrollTop
}; };
}); });
})();
} }
$$b(window).resize(function (evt) { $$b(window).resize(function (evt) {
@ -32481,8 +32480,6 @@
}); });
setFlyoutPositions(); setFlyoutPositions();
}); });
(function () {
workarea.scroll(function () { workarea.scroll(function () {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($$b('#ruler_x').length) { if ($$b('#ruler_x').length) {
@ -32493,8 +32490,6 @@
$$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop; $$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
} }
}); });
})();
$$b('#url_notice').click(function () { $$b('#url_notice').click(function () {
$$b.alert(this.title); $$b.alert(this.title);
}); });
@ -34050,14 +34045,11 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // $(function () { } // const revnums = 'svg-editor.js ($Rev$) ';
updateCanvas(true); // });
// const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang

View File

@ -20965,8 +20965,8 @@
var bg = $$9('#canvasBackground')[0]; var bg = $$9('#canvasBackground')[0];
var oldX = svgcontent.getAttribute('x'); var oldX = svgcontent.getAttribute('x');
var oldY = svgcontent.getAttribute('y'); var oldY = svgcontent.getAttribute('y');
var x = w / 2 - this.contentW * currentZoom / 2; var x = (w - this.contentW * currentZoom) / 2;
var y = h / 2 - this.contentH * currentZoom / 2; var y = (h - this.contentH * currentZoom) / 2;
assignAttributes(svgcontent, { assignAttributes(svgcontent, {
width: this.contentW * currentZoom, width: this.contentW * currentZoom,
height: this.contentH * currentZoom, height: this.contentH * currentZoom,
@ -28453,6 +28453,7 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
updateCanvas(true);
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -32444,7 +32445,6 @@
}; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9) }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) { if (isIE()) {
(function () {
resetScrollPos = function resetScrollPos() { resetScrollPos = function resetScrollPos() {
if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) { if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
workarea[0].scrollLeft = curScrollPos.left; workarea[0].scrollLeft = curScrollPos.left;
@ -32470,7 +32470,6 @@
top: workarea[0].scrollTop top: workarea[0].scrollTop
}; };
}); });
})();
} }
$$b(window).resize(function (evt) { $$b(window).resize(function (evt) {
@ -32481,8 +32480,6 @@
}); });
setFlyoutPositions(); setFlyoutPositions();
}); });
(function () {
workarea.scroll(function () { workarea.scroll(function () {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($$b('#ruler_x').length) { if ($$b('#ruler_x').length) {
@ -32493,8 +32490,6 @@
$$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop; $$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
} }
}); });
})();
$$b('#url_notice').click(function () { $$b('#url_notice').click(function () {
$$b.alert(this.title); $$b.alert(this.title);
}); });
@ -34050,14 +34045,11 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // $(function () { } // const revnums = 'svg-editor.js ($Rev$) ';
updateCanvas(true); // });
// const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang