#45 These buttons don't work and dropdown is broken

master
Agriya Dev5 2021-02-17 16:09:20 +05:30
parent 47c365bf2a
commit 2f2dd0fc56
3 changed files with 16 additions and 5 deletions

View File

@ -130,6 +130,7 @@ export class SeList extends HTMLElement {
const value = this.$dropdown.selectedItem.getAttribute('value'); const value = this.$dropdown.selectedItem.getAttribute('value');
const closeEvent = new CustomEvent('change', {detail: {value}}); const closeEvent = new CustomEvent('change', {detail: {value}});
currentObj.dispatchEvent(closeEvent); currentObj.dispatchEvent(closeEvent);
currentObj.value = value;
} }
}); });
} }

View File

@ -398,7 +398,11 @@ class TopPanelHandlers {
* @returns {void} * @returns {void}
*/ */
clickAlign (pos) { clickAlign (pos) {
this.svgCanvas.alignSelectedElements(pos, $('#align_relative_to').val()); let value = $('#tool_align_relative').val();
if(value === ''){
value = 'selected';
}
this.svgCanvas.alignSelectedElements(pos, value);
} }
/** /**
* *

View File

@ -288,9 +288,9 @@ export const alignSelectedElements = function (type, relativeTo) {
// now bbox is axis-aligned and handles rotation // now bbox is axis-aligned and handles rotation
switch (relativeTo) { switch (relativeTo) {
case 'smallest': case 'smallest':
if (((type === 'l' || type === 'c' || type === 'r') && if (((type === 'l' || type === 'c' || type === 'r' || type === 'left' || type === 'center' || type === 'right') &&
(curwidth === Number.MIN_VALUE || curwidth > bboxes[i].width)) || (curwidth === Number.MIN_VALUE || curwidth > bboxes[i].width)) ||
((type === 't' || type === 'm' || type === 'b') && ((type === 't' || type === 'm' || type === 'b' || type === 'top' || type === 'middle' || type === 'bottom') &&
(curheight === Number.MIN_VALUE || curheight > bboxes[i].height)) (curheight === Number.MIN_VALUE || curheight > bboxes[i].height))
) { ) {
minx = bboxes[i].x; minx = bboxes[i].x;
@ -302,9 +302,9 @@ export const alignSelectedElements = function (type, relativeTo) {
} }
break; break;
case 'largest': case 'largest':
if (((type === 'l' || type === 'c' || type === 'r') && if (((type === 'l' || type === 'c' || type === 'r' || type === 'left' || type === 'center' || type === 'right') &&
(curwidth === Number.MIN_VALUE || curwidth < bboxes[i].width)) || (curwidth === Number.MIN_VALUE || curwidth < bboxes[i].width)) ||
((type === 't' || type === 'm' || type === 'b') && ((type === 't' || type === 'm' || type === 'b' || type === 'top' || type === 'middle' || type === 'bottom') &&
(curheight === Number.MIN_VALUE || curheight < bboxes[i].height)) (curheight === Number.MIN_VALUE || curheight < bboxes[i].height))
) { ) {
minx = bboxes[i].x; minx = bboxes[i].x;
@ -341,21 +341,27 @@ export const alignSelectedElements = function (type, relativeTo) {
dy[i] = 0; dy[i] = 0;
switch (type) { switch (type) {
case 'l': // left (horizontal) case 'l': // left (horizontal)
case 'left': // left (horizontal)
dx[i] = minx - bbox.x; dx[i] = minx - bbox.x;
break; break;
case 'c': // center (horizontal) case 'c': // center (horizontal)
case 'center': // center (horizontal)
dx[i] = (minx + maxx) / 2 - (bbox.x + bbox.width / 2); dx[i] = (minx + maxx) / 2 - (bbox.x + bbox.width / 2);
break; break;
case 'r': // right (horizontal) case 'r': // right (horizontal)
case 'right': // right (horizontal)
dx[i] = maxx - (bbox.x + bbox.width); dx[i] = maxx - (bbox.x + bbox.width);
break; break;
case 't': // top (vertical) case 't': // top (vertical)
case 'top': // top (vertical)
dy[i] = miny - bbox.y; dy[i] = miny - bbox.y;
break; break;
case 'm': // middle (vertical) case 'm': // middle (vertical)
case 'middle': // middle (vertical)
dy[i] = (miny + maxy) / 2 - (bbox.y + bbox.height / 2); dy[i] = (miny + maxy) / 2 - (bbox.y + bbox.height / 2);
break; break;
case 'b': // bottom (vertical) case 'b': // bottom (vertical)
case 'bottom': // bottom (vertical)
dy[i] = maxy - (bbox.y + bbox.height); dy[i] = maxy - (bbox.y + bbox.height);
break; break;
} }