fix issues with svgtransform

This commit is contained in:
JFH
2021-08-29 16:05:56 +02:00
parent a74f5cb4df
commit 5846eca53f
5 changed files with 7 additions and 8 deletions

View File

@@ -141,7 +141,7 @@ export const mouseMoveEvent = function (evt) {
// update the dummy transform in our transform list
// to be a translate
const xform = svgRoot.createSVGTransform();
tlist = selected.transform.baseVal;
tlist = selected.transform?.baseVal;
// Note that if Webkit and there's no ID for this
// element, the dummy transform may have gotten lost.
// This results in unexpected behaviour
@@ -1043,7 +1043,7 @@ export const mouseDownEvent = function (evt) {
// a transform to use for its translate
for (const selectedElement of selectedElements()) {
if (isNullish(selectedElement)) { continue; }
const slist = selectedElement.transform.baseVal;
const slist = selectedElement.transform?.baseVal;
if (slist.numberOfItems) {
slist.insertItemBefore(svgRoot.createSVGTransform(), 0);
} else {

View File

@@ -242,7 +242,6 @@ export class RemoveElementCommand extends Command {
*/
apply (handler) {
super.apply(handler, () => {
this.removeElementFromListMap();
this.parent = this.elem.parentNode;
this.elem.remove();
});

View File

@@ -76,7 +76,7 @@ export const recalculateDimensions = function (selected) {
if (!selected) return null;
const svgroot = context_.getSVGRoot();
const dataStorage = context_.getDataStorage();
const tlist = selected.transform.baseVal;
const tlist = selected.transform?.baseVal;
// remove any unnecessary transforms
if (tlist && tlist.numberOfItems > 0) {
let k = tlist.numberOfItems;
@@ -477,7 +477,7 @@ export const recalculateDimensions = function (selected) {
if (child.nodeType === 1) {
oldStartTransform = context_.getStartTransform();
context_.setStartTransform(child.getAttribute('transform'));
const childTlist = child.transform.baseVal;
const childTlist = child.transform?.baseVal;
if (!childTlist) { continue; }
@@ -558,7 +558,7 @@ export const recalculateDimensions = function (selected) {
if (child.nodeType === 1) {
oldStartTransform = context_.getStartTransform();
context_.setStartTransform(child.getAttribute('transform'));
const childTlist = child.transform.baseVal;
const childTlist = child.transform?.baseVal;
const newxlate = svgroot.createSVGTransform();
newxlate.setTranslate(tx, ty);
if (childTlist.numberOfItems) {

View File

@@ -168,7 +168,7 @@ export const moveSelectedElements = function (dx, dy, undoable = true) {
const selected = selectedElements[i];
if (!isNullish(selected)) {
const xform = elementContext_.getSVGRoot().createSVGTransform();
const tlist = selected.transform.baseVal;
const tlist = selected.transform?.baseVal;
// dx and dy could be arrays
if (Array.isArray(dx)) {

View File

@@ -161,7 +161,7 @@ export const getMouseTargetMethod = function (evt) {
return svgCanvas.selectorManager.selectorParentGroup;
}
while (!mouseTarget.parentNode?.isSameNode(selectionContext_.getCurrentGroup() || currentLayer)) {
while (!mouseTarget?.parentNode?.isSameNode(selectionContext_.getCurrentGroup() || currentLayer)) {
mouseTarget = mouseTarget.parentNode;
}