Made SVG drawing MS Edge compatible (issue #7)

This commit is contained in:
Rainer Simon 2020-05-05 13:24:49 +02:00
parent 41529a4cd1
commit eedbe77e22
3 changed files with 34 additions and 35 deletions

View File

@ -47,15 +47,15 @@ export default class Bounds {
/** Translates DOMRect client bounds to offset bounds within the given container **/
const toOffsetBounds = (clientBounds, offsetContainer) => {
const { x, y } = offsetContainer.getBoundingClientRect();
const left = Math.round(clientBounds.left - x);
const top = Math.round(clientBounds.top - y);
const { top, left } = offsetContainer.getBoundingClientRect();
const l = Math.round(clientBounds.left - left);
const t = Math.round(clientBounds.top - top);
return {
left : left,
top : top,
right : Math.round(left + clientBounds.width),
bottom: Math.round(top + clientBounds.height),
left : l,
top : t,
right : Math.round(l + clientBounds.width),
bottom: Math.round(t + clientBounds.height),
width : Math.round(clientBounds.width),
height: Math.round(clientBounds.height)
};

View File

@ -245,4 +245,3 @@ export default class Connection extends EventEmitter {
}
}

View File

@ -72,8 +72,8 @@ export default class DrawingTool extends EventEmitter {
if (this.currentHover) {
this.currentConnection.dragTo(this.currentHover.node);
} else {
const { x, y } = this.contentEl.getBoundingClientRect();
this.currentConnection.dragTo([ evt.pageX - x, evt.pageY - y]);
const { top, left } = this.contentEl.getBoundingClientRect();
this.currentConnection.dragTo([ evt.pageX - left, evt.pageY - top ]);
}
}
}