mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-21 22:27:56 +01:00
Merged in eslint-prettier-config (pull request #53)
Eslint prettier config * config eslint + manual fixes * Merge branch 'develop' into eslint-prettier-config * fixes eslint web2d Approved-by: Paulo Veiga
This commit is contained in:
parent
5ee7448d3c
commit
19353a9423
@ -22,7 +22,7 @@
|
|||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
// ignore errores when a line finishes with (setting this value to 0 ignores all errors)
|
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
|
||||||
"operator-linebreak": [
|
"operator-linebreak": [
|
||||||
"error", "after", {
|
"error", "after", {
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
@ -33,7 +33,8 @@ class OriginalLayout {
|
|||||||
$assert(position, 'position can not be null');
|
$assert(position, 'position can not be null');
|
||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
|
|
||||||
const strategy = type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
|
const strategy =
|
||||||
|
type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
|
||||||
return new Node(id, size, position, strategy);
|
return new Node(id, size, position, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class OriginalLayout {
|
|||||||
/** */
|
/** */
|
||||||
layout() {
|
layout() {
|
||||||
const roots = this._treeSet.getTreeRoots();
|
const roots = this._treeSet.getTreeRoots();
|
||||||
roots.forEach(((node) => {
|
roots.forEach((node) => {
|
||||||
// Calculate all node heights ...
|
// Calculate all node heights ...
|
||||||
const sorter = node.getSorter();
|
const sorter = node.getSorter();
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ class OriginalLayout {
|
|||||||
this._layoutChildren(node, heightById);
|
this._layoutChildren(node, heightById);
|
||||||
|
|
||||||
this._fixOverlapping(node, heightById);
|
this._fixOverlapping(node, heightById);
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_layoutChildren(node, heightById) {
|
_layoutChildren(node, heightById) {
|
||||||
@ -117,8 +118,8 @@ class OriginalLayout {
|
|||||||
const direction = node.getSorter().getChildDirection(me._treeSet, child);
|
const direction = node.getSorter().getChildDirection(me._treeSet, child);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(direction > 0 && childFreeDisplacement.x < 0)
|
(direction > 0 && childFreeDisplacement.x < 0) ||
|
||||||
|| (direction < 0 && childFreeDisplacement.x > 0)
|
(direction < 0 && childFreeDisplacement.x > 0)
|
||||||
) {
|
) {
|
||||||
child.resetFreeDisplacement();
|
child.resetFreeDisplacement();
|
||||||
child.setFreeDisplacement({
|
child.setFreeDisplacement({
|
||||||
@ -145,9 +146,9 @@ class OriginalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue reordering the children nodes ...
|
// Continue reordering the children nodes ...
|
||||||
children.forEach(((child) => {
|
children.forEach((child) => {
|
||||||
this._layoutChildren(child, heightById);
|
this._layoutChildren(child, heightById);
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateAlignOffset(node, child, heightById) {
|
_calculateAlignOffset(node, child, heightById) {
|
||||||
@ -161,12 +162,13 @@ class OriginalLayout {
|
|||||||
const childHeight = child.getSize().height;
|
const childHeight = child.getSize().height;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this._treeSet.isStartOfSubBranch(child)
|
this._treeSet.isStartOfSubBranch(child) &&
|
||||||
&& OriginalLayout._branchIsTaller(child, heightById)
|
OriginalLayout._branchIsTaller(child, heightById)
|
||||||
) {
|
) {
|
||||||
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
||||||
offset = heightById[child.getId()] / 2
|
offset =
|
||||||
- (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
|
heightById[child.getId()] / 2 -
|
||||||
|
(childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
|
||||||
} else {
|
} else {
|
||||||
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
|
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
|
||||||
}
|
}
|
||||||
@ -189,8 +191,7 @@ class OriginalLayout {
|
|||||||
|
|
||||||
static _branchIsTaller(node, heightById) {
|
static _branchIsTaller(node, heightById) {
|
||||||
return (
|
return (
|
||||||
heightById[node.getId()]
|
heightById[node.getId()] > node.getSize().height + node.getSorter()._getVerticalPadding() * 2
|
||||||
> node.getSize().height + node.getSorter()._getVerticalPadding() * 2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +201,9 @@ class OriginalLayout {
|
|||||||
if (node.isFree()) {
|
if (node.isFree()) {
|
||||||
this._shiftBranches(node, heightById);
|
this._shiftBranches(node, heightById);
|
||||||
}
|
}
|
||||||
children.forEach(((child) => {
|
children.forEach((child) => {
|
||||||
this._fixOverlapping(child, heightById);
|
this._fixOverlapping(child, heightById);
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_shiftBranches(node, heightById) {
|
_shiftBranches(node, heightById) {
|
||||||
@ -213,27 +214,28 @@ class OriginalLayout {
|
|||||||
node.getFreeDisplacement().y,
|
node.getFreeDisplacement().y,
|
||||||
);
|
);
|
||||||
|
|
||||||
siblingsToShift.forEach(((sibling) => {
|
siblingsToShift.forEach((sibling) => {
|
||||||
const overlappingOccurs = shiftedBranches.some(
|
/* eslint-disable */
|
||||||
((shiftedBranch) => OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById)),
|
const overlappingOccurs = shiftedBranches.some((shiftedBranch) =>
|
||||||
|
OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById),
|
||||||
);
|
);
|
||||||
|
/* eslint-enable */
|
||||||
if (!sibling.isFree() || overlappingOccurs) {
|
if (!sibling.isFree() || overlappingOccurs) {
|
||||||
const sAmount = node.getFreeDisplacement().y;
|
const sAmount = node.getFreeDisplacement().y;
|
||||||
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
|
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
|
||||||
shiftedBranches.push(sibling);
|
shiftedBranches.push(sibling);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
const branchesToShift = this._treeSet
|
const branchesToShift = this._treeSet
|
||||||
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
|
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
|
||||||
.filter((branch) => !shiftedBranches.includes(branch));
|
.filter((branch) => !shiftedBranches.includes(branch));
|
||||||
|
|
||||||
branchesToShift.forEach(((branch) => {
|
branchesToShift.forEach((branch) => {
|
||||||
const bAmount = node.getFreeDisplacement().y;
|
const bAmount = node.getFreeDisplacement().y;
|
||||||
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
||||||
shiftedBranches.push(branch);
|
shiftedBranches.push(branch);
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static _branchesOverlap(branchA, branchB, heightById) {
|
static _branchesOverlap(branchA, branchB, heightById) {
|
||||||
|
@ -75,9 +75,7 @@ class BootstrapDialog extends Options {
|
|||||||
)}</button>`,
|
)}</button>`,
|
||||||
);
|
);
|
||||||
footer.append(this.acceptButton);
|
footer.append(this.acceptButton);
|
||||||
this.acceptButton
|
this.acceptButton.unbind('click').on('click', this.options.onEventData, this.onAcceptClick);
|
||||||
.unbind('click')
|
|
||||||
.on('click', this.options.onEventData, this.onAcceptClick);
|
|
||||||
}
|
}
|
||||||
if (this.options.removeButton) {
|
if (this.options.removeButton) {
|
||||||
this.removeButton = $(
|
this.removeButton = $(
|
||||||
|
@ -15,7 +15,25 @@
|
|||||||
"import/no-extraneous-dependencies": ["warn", {
|
"import/no-extraneous-dependencies": ["warn", {
|
||||||
"packageDir": ["./"],
|
"packageDir": ["./"],
|
||||||
"devDependencies": ["!cypress/**/*.js"]
|
"devDependencies": ["!cypress/**/*.js"]
|
||||||
}]
|
}],
|
||||||
|
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
|
||||||
|
"operator-linebreak": [
|
||||||
|
"error", "after", {
|
||||||
|
"overrides": {
|
||||||
|
"+": "ignore",
|
||||||
|
"-": "ignore",
|
||||||
|
":": "ignore",
|
||||||
|
"*": "ignore",
|
||||||
|
"?": "ignore",
|
||||||
|
">": "ignore",
|
||||||
|
"||": "ignore",
|
||||||
|
"&&": "ignore",
|
||||||
|
"(": "ignore"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"object-curly-newline": "off",
|
||||||
|
"indent": "off"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"import/resolver": {
|
"import/resolver": {
|
||||||
|
@ -76,17 +76,17 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the registration of event listeners on the event target.
|
* Allows the registration of event listeners on the event target.
|
||||||
* type
|
* type
|
||||||
* A string representing the event type to listen for.
|
* A string representing the event type to listen for.
|
||||||
* listener
|
* listener
|
||||||
* The object that receives a notification when an event of the
|
* The object that receives a notification when an event of the
|
||||||
* specified type occurs. This must be an object implementing the
|
* specified type occurs. This must be an object implementing the
|
||||||
* EventListener interface, or simply a function in JavaScript.
|
* EventListener interface, or simply a function in JavaScript.
|
||||||
*
|
*
|
||||||
* The following events types are supported:
|
* The following events types are supported:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addEvent(type, listener) {
|
addEvent(type, listener) {
|
||||||
this.peer.addEvent(type, listener);
|
this.peer.addEvent(type, listener);
|
||||||
}
|
}
|
||||||
@ -100,26 +100,26 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Allows the removal of event listeners from the event target.
|
* Allows the removal of event listeners from the event target.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* type
|
* type
|
||||||
* A string representing the event type being registered.
|
* A string representing the event type being registered.
|
||||||
* listener
|
* listener
|
||||||
* The listener parameter takes an interface implemented by
|
* The listener parameter takes an interface implemented by
|
||||||
* the user which contains the methods to be called when the event occurs.
|
* the user which contains the methods to be called when the event occurs.
|
||||||
* This interace will be invoked passing an event as argument and
|
* This interace will be invoked passing an event as argument and
|
||||||
* the 'this' referece in the function will be the element.
|
* the 'this' referece in the function will be the element.
|
||||||
*/
|
*/
|
||||||
removeEvent(type, listener) {
|
removeEvent(type, listener) {
|
||||||
this.peer.removeEvent(type, listener);
|
this.peer.removeEvent(type, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* /*
|
* /*
|
||||||
* Returns element type name.
|
* Returns element type name.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
getType() {
|
getType() {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -128,17 +128,17 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Todo: Doc
|
* Todo: Doc
|
||||||
*/
|
*/
|
||||||
getFill() {
|
getFill() {
|
||||||
return this.peer.getFill();
|
return this.peer.getFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to define the fill element color and element opacity.
|
* Used to define the fill element color and element opacity.
|
||||||
* color: Fill color
|
* color: Fill color
|
||||||
* opacity: Opacity of the fill. It must be less than 1.
|
* opacity: Opacity of the fill. It must be less than 1.
|
||||||
*/
|
*/
|
||||||
setFill(color, opacity) {
|
setFill(color, opacity) {
|
||||||
this.peer.setFill(color, opacity);
|
this.peer.setFill(color, opacity);
|
||||||
}
|
}
|
||||||
@ -152,21 +152,21 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines the element stroke properties.
|
* Defines the element stroke properties.
|
||||||
* width: stroke width
|
* width: stroke width
|
||||||
* style: "solid|dot|dash|dashdot|longdash".
|
* style: "solid|dot|dash|dashdot|longdash".
|
||||||
* color: stroke color
|
* color: stroke color
|
||||||
* opacity: stroke visibility
|
* opacity: stroke visibility
|
||||||
*/
|
*/
|
||||||
setStroke(width, style, color, opacity) {
|
setStroke(width, style, color, opacity) {
|
||||||
if (
|
if (
|
||||||
style != null
|
style != null &&
|
||||||
&& style !== undefined
|
style !== undefined &&
|
||||||
&& style !== 'dash'
|
style !== 'dash' &&
|
||||||
&& style !== 'dot'
|
style !== 'dot' &&
|
||||||
&& style !== 'solid'
|
style !== 'solid' &&
|
||||||
&& style !== 'longdash'
|
style !== 'longdash' &&
|
||||||
&& style !== 'dashdot'
|
style !== 'dashdot'
|
||||||
) {
|
) {
|
||||||
throw new Error(`Unsupported stroke style: '${style}'`);
|
throw new Error(`Unsupported stroke style: '${style}'`);
|
||||||
}
|
}
|
||||||
@ -185,13 +185,13 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All element properties can be setted using either a method
|
* All element properties can be setted using either a method
|
||||||
* invocation or attribute invocation.
|
* invocation or attribute invocation.
|
||||||
* key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle,
|
* key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle,
|
||||||
* strokeColor, strokeOpacity,
|
* strokeColor, strokeOpacity,
|
||||||
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight,
|
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight,
|
||||||
* coordOrigin, coordOriginX, coordOrigiY
|
* coordOrigin, coordOriginX, coordOrigiY
|
||||||
*/
|
*/
|
||||||
setAttribute(key, value) {
|
setAttribute(key, value) {
|
||||||
const funcName = this._attributeNameToFuncName(key, 'set');
|
const funcName = this._attributeNameToFuncName(key, 'set');
|
||||||
|
|
||||||
@ -246,10 +246,10 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the element opacity.
|
* Defines the element opacity.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* opacity: A value between 0 and 1.
|
* opacity: A value between 0 and 1.
|
||||||
*/
|
*/
|
||||||
setOpacity(opacity) {
|
setOpacity(opacity) {
|
||||||
this.peer.setStroke(null, null, null, opacity);
|
this.peer.setStroke(null, null, null, opacity);
|
||||||
this.peer.setFill(null, opacity);
|
this.peer.setFill(null, opacity);
|
||||||
@ -264,15 +264,15 @@ class ElementClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the element to the front
|
* Move the element to the front
|
||||||
*/
|
*/
|
||||||
moveToFront() {
|
moveToFront() {
|
||||||
this.peer.moveToFront();
|
this.peer.moveToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the element to the back
|
* Move the element to the back
|
||||||
*/
|
*/
|
||||||
moveToBack() {
|
moveToBack() {
|
||||||
this.peer.moveToBack();
|
this.peer.moveToBack();
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,7 @@ class ArrowPeer extends ElementPeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDashed(isDashed, length, spacing) {
|
setDashed(isDashed, length, spacing) {
|
||||||
if (
|
if ($defined(isDashed) && isDashed && $defined(length) && $defined(spacing)) {
|
||||||
$defined(isDashed)
|
|
||||||
&& isDashed
|
|
||||||
&& $defined(length)
|
|
||||||
&& $defined(spacing)
|
|
||||||
) {
|
|
||||||
this._native.setAttribute('stroke-dasharray', `${length}${spacing}`);
|
this._native.setAttribute('stroke-dasharray', `${length}${spacing}`);
|
||||||
} else {
|
} else {
|
||||||
this._native.setAttribute('stroke-dasharray', '');
|
this._native.setAttribute('stroke-dasharray', '');
|
||||||
@ -77,10 +72,10 @@ class ArrowPeer extends ElementPeer {
|
|||||||
let xp;
|
let xp;
|
||||||
let yp;
|
let yp;
|
||||||
if (
|
if (
|
||||||
$defined(this._fromPoint.x)
|
$defined(this._fromPoint.x) &&
|
||||||
&& $defined(this._fromPoint.y)
|
$defined(this._fromPoint.y) &&
|
||||||
&& $defined(this._controlPoint.x)
|
$defined(this._controlPoint.x) &&
|
||||||
&& $defined(this._controlPoint.y)
|
$defined(this._controlPoint.y)
|
||||||
) {
|
) {
|
||||||
if (this._controlPoint.y === 0) this._controlPoint.y = 1;
|
if (this._controlPoint.y === 0) this._controlPoint.y = 1;
|
||||||
|
|
||||||
@ -103,10 +98,12 @@ class ArrowPeer extends ElementPeer {
|
|||||||
xp *= Math.sign(x3);
|
xp *= Math.sign(x3);
|
||||||
yp = x3 === 0 ? l * Math.sign(y3) : mp * xp;
|
yp = x3 === 0 ? l * Math.sign(y3) : mp * xp;
|
||||||
|
|
||||||
const path = `M${this._fromPoint.x},${this._fromPoint.y} `
|
const path =
|
||||||
+ `L${x + this._fromPoint.x},${y + this._fromPoint.y} M${this._fromPoint.x},${this._fromPoint.y
|
`M${this._fromPoint.x},${this._fromPoint.y} ` +
|
||||||
} `
|
`L${x + this._fromPoint.x},${y + this._fromPoint.y} M${this._fromPoint.x},${
|
||||||
+ `L${xp + this._fromPoint.x},${yp + this._fromPoint.y}`;
|
this._fromPoint.y
|
||||||
|
} ` +
|
||||||
|
`L${xp + this._fromPoint.x},${yp + this._fromPoint.y}`;
|
||||||
this._native.setAttribute('d', path);
|
this._native.setAttribute('d', path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,19 +148,25 @@ class CurvedLinePeer extends ElementPeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updatePath(avoidControlPointFix) {
|
_updatePath(avoidControlPointFix) {
|
||||||
if (
|
if ($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2)) {
|
||||||
$defined(this._x1)
|
|
||||||
&& $defined(this._y1)
|
|
||||||
&& $defined(this._x2)
|
|
||||||
&& $defined(this._y2)
|
|
||||||
) {
|
|
||||||
this._calculateAutoControlPoints(avoidControlPointFix);
|
this._calculateAutoControlPoints(avoidControlPointFix);
|
||||||
|
|
||||||
const path = `M${this._x1.toFixed(2)},${this._y1.toFixed(2)} C${(this._control1.x + this._x1).toFixed(2)},${this._control1.y + this._y1
|
const path = `M${this._x1.toFixed(2)},${this._y1.toFixed(2)} C${(
|
||||||
} ${(this._control2.x + this._x2).toFixed(2)},${(this._control2.y + this._y2).toFixed(2)} ${(this._x2).toFixed(2)},${(this._y2).toFixed(2)}${this._lineStyle
|
this._control1.x + this._x1
|
||||||
? ` ${(this._control2.x + this._x2).toFixed(2)},${(this._control2.y + this._y2 + 3).toFixed(2)} ${(this._control1.x + this._x1
|
).toFixed(2)},${this._control1.y + this._y1} ${(this._control2.x + this._x2).toFixed(2)},${(
|
||||||
).toFixed(2)},${(this._control1.y + this._y1 + 5).toFixed(2)} ${this._x1.toFixed(2)},${(this._y1 + 7).toFixed(2)} Z`
|
this._control2.y + this._y2
|
||||||
: ''
|
).toFixed(2)} ${this._x2.toFixed(2)},${this._y2.toFixed(2)}${
|
||||||
|
this._lineStyle
|
||||||
|
? ` ${(this._control2.x + this._x2).toFixed(2)},${(
|
||||||
|
this._control2.y +
|
||||||
|
this._y2 +
|
||||||
|
3
|
||||||
|
).toFixed(2)} ${(this._control1.x + this._x1).toFixed(2)},${(
|
||||||
|
this._control1.y +
|
||||||
|
this._y1 +
|
||||||
|
5
|
||||||
|
).toFixed(2)} ${this._x1.toFixed(2)},${(this._y1 + 7).toFixed(2)} Z`
|
||||||
|
: ''
|
||||||
}`;
|
}`;
|
||||||
this._native.setAttribute('d', path);
|
this._native.setAttribute('d', path);
|
||||||
}
|
}
|
||||||
@ -193,10 +199,7 @@ class CurvedLinePeer extends ElementPeer {
|
|||||||
const x2 = tarPos.x + Math.sqrt((l * l) / (1 + m * m)) * fix * -1;
|
const x2 = tarPos.x + Math.sqrt((l * l) / (1 + m * m)) * fix * -1;
|
||||||
const y2 = m * (x2 - tarPos.x) + tarPos.y;
|
const y2 = m * (x2 - tarPos.x) + tarPos.y;
|
||||||
|
|
||||||
return [
|
return [new Point(-srcPos.x + x1, -srcPos.y + y1), new Point(-tarPos.x + x2, -tarPos.y + y2)];
|
||||||
new Point(-srcPos.x + x1, -srcPos.y + y1),
|
|
||||||
new Point(-tarPos.x + x2, -tarPos.y + y2),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateAutoControlPoints(avoidControlPointFix) {
|
_calculateAutoControlPoints(avoidControlPointFix) {
|
||||||
@ -206,15 +209,15 @@ class CurvedLinePeer extends ElementPeer {
|
|||||||
new Point(this._x2, this._y2),
|
new Point(this._x2, this._y2),
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
!this._customControlPoint_1
|
!this._customControlPoint_1 &&
|
||||||
&& !($defined(avoidControlPointFix) && avoidControlPointFix === 0)
|
!($defined(avoidControlPointFix) && avoidControlPointFix === 0)
|
||||||
) {
|
) {
|
||||||
this._control1.x = defaultpoints[0].x;
|
this._control1.x = defaultpoints[0].x;
|
||||||
this._control1.y = defaultpoints[0].y;
|
this._control1.y = defaultpoints[0].y;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!this._customControlPoint_2
|
!this._customControlPoint_2 &&
|
||||||
&& !($defined(avoidControlPointFix) && avoidControlPointFix === 1)
|
!($defined(avoidControlPointFix) && avoidControlPointFix === 1)
|
||||||
) {
|
) {
|
||||||
this._control2.x = defaultpoints[1].x;
|
this._control2.x = defaultpoints[1].x;
|
||||||
this._control2.y = defaultpoints[1].y;
|
this._control2.y = defaultpoints[1].y;
|
||||||
|
@ -39,9 +39,11 @@ export const getPosition = (elem) => {
|
|||||||
// when a statically positioned element is identified
|
// when a statically positioned element is identified
|
||||||
doc = elem.ownerDocument;
|
doc = elem.ownerDocument;
|
||||||
offsetParent = elem.offsetParent || doc.documentElement;
|
offsetParent = elem.offsetParent || doc.documentElement;
|
||||||
while (offsetParent
|
while (
|
||||||
&& (offsetParent === doc.body || offsetParent === doc.documentElement)
|
offsetParent &&
|
||||||
&& getStyle(offsetParent, 'position') === 'static') {
|
(offsetParent === doc.body || offsetParent === doc.documentElement) &&
|
||||||
|
getStyle(offsetParent, 'position') === 'static'
|
||||||
|
) {
|
||||||
offsetParent = offsetParent.parentNode;
|
offsetParent = offsetParent.parentNode;
|
||||||
}
|
}
|
||||||
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
|
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
|
||||||
|
@ -28,16 +28,4 @@ import Text from './components/Text';
|
|||||||
import Point from './components/Point';
|
import Point from './components/Point';
|
||||||
import Image from './components/Image';
|
import Image from './components/Image';
|
||||||
|
|
||||||
export {
|
export { Arrow, CurvedLine, Elipse, Group, Image, Line, Point, PolyLine, Rect, Text, Workspace };
|
||||||
Arrow,
|
|
||||||
CurvedLine,
|
|
||||||
Elipse,
|
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Line,
|
|
||||||
Point,
|
|
||||||
PolyLine,
|
|
||||||
Rect,
|
|
||||||
Text,
|
|
||||||
Workspace,
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user