更新logicflow包
This commit is contained in:
1 parent
e78ebb747d
commit
2583575725
113 files changed
+41211
-588
No files matched your search
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
@@ -29,17 +40,36 @@ var __read = (this && this.__read) || function (o, n) {
|
||||
return ar;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CurvedEdge = void 0;
|
||||
exports.CurvedEdgeModel = exports.CurvedEdge = void 0;
|
||||
var core_1 = require("@logicflow/core");
|
||||
var CurvedEdgeView = /** @class */ (function (_super) {
|
||||
__extends(CurvedEdgeView, _super);
|
||||
function CurvedEdgeView() {
|
||||
var CurvedEdge = /** @class */ (function (_super) {
|
||||
__extends(CurvedEdge, _super);
|
||||
function CurvedEdge() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
CurvedEdgeView.prototype.getEdge = function () {
|
||||
var _a = this.props.model.getEdgeStyle(), strokeWidth = _a.strokeWidth, stroke = _a.stroke, strokeDashArray = _a.strokeDashArray;
|
||||
var points = this.props.model.points;
|
||||
var points2 = points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); });
|
||||
CurvedEdge.prototype.pointFilter = function (points) {
|
||||
var allPoints = points;
|
||||
var i = 1;
|
||||
while (i < allPoints.length - 1) {
|
||||
var _a = __read(allPoints[i - 1], 2), x = _a[0], y = _a[1];
|
||||
var _b = __read(allPoints[i], 2), x1 = _b[0], y1 = _b[1];
|
||||
var _c = __read(allPoints[i + 1], 2), x2 = _c[0], y2 = _c[1];
|
||||
if ((x === x1 && x1 === x2)
|
||||
|| (y === y1 && y1 === y2)) {
|
||||
allPoints.splice(i, 1);
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return allPoints;
|
||||
};
|
||||
CurvedEdge.prototype.getEdge = function () {
|
||||
var model = this.props.model;
|
||||
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, _a = model.radius, radius = _a === void 0 ? 5 : _a;
|
||||
var style = model.getEdgeStyle();
|
||||
var animationStyle = model.getEdgeAnimationStyle();
|
||||
var points2 = this.pointFilter(points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); }));
|
||||
var _b = __read(points2[0], 2), startX = _b[0], startY = _b[1];
|
||||
var d = "M" + startX + " " + startY;
|
||||
// 1) 如果一个点不为开始和结束,则在这个点的前后增加弧度开始和结束点。
|
||||
@@ -47,43 +77,36 @@ var CurvedEdgeView = /** @class */ (function (_super) {
|
||||
// 如果x相同则前一个点的x也不变,
|
||||
// y为(这个点的y 大于前一个点的y, 则 为 这个点的y - 5;小于前一个点的y, 则为这个点的y+5)
|
||||
// 同理,判断这个点与后一个点的x,y是否相同,如果x相同,则y进行加减,如果y相同,则x进行加减
|
||||
// todo: 好丑,看看怎么优化下
|
||||
var space = 5;
|
||||
for (var i = 1; i < points2.length - 1; i++) {
|
||||
var _c = __read(points2[i - 1], 2), preX = _c[0], preY = _c[1];
|
||||
var _d = __read(points2[i], 2), currentX = _d[0], currentY = _d[1];
|
||||
var _e = __read(points2[i + 1], 2), nextX = _e[0], nextY = _e[1];
|
||||
if (currentX === preX && currentY !== preY) {
|
||||
var y = currentY > preY ? currentY - space : currentY + space;
|
||||
var y = currentY > preY ? currentY - radius : currentY + radius;
|
||||
d = d + " L " + currentX + " " + y;
|
||||
}
|
||||
if (currentY === preY && currentX !== preX) {
|
||||
var x = currentX > preX ? currentX - space : currentX + space;
|
||||
var x = currentX > preX ? currentX - radius : currentX + radius;
|
||||
d = d + " L " + x + " " + currentY;
|
||||
}
|
||||
d = d + " Q " + currentX + " " + currentY;
|
||||
if (currentX === nextX && currentY !== nextY) {
|
||||
var y = currentY > nextY ? currentY - space : currentY + space;
|
||||
var y = currentY > nextY ? currentY - radius : currentY + radius;
|
||||
d = d + " " + currentX + " " + y;
|
||||
}
|
||||
if (currentY === nextY && currentX !== nextX) {
|
||||
var x = currentX > nextX ? currentX - space : currentX + space;
|
||||
var x = currentX > nextX ? currentX - radius : currentX + radius;
|
||||
d = d + " " + x + " " + currentY;
|
||||
}
|
||||
}
|
||||
var _f = __read(points2[points2.length - 1], 2), endX = _f[0], endY = _f[1];
|
||||
d = d + " L " + endX + " " + endY;
|
||||
return core_1.h('path', {
|
||||
d: d,
|
||||
strokeWidth: strokeWidth,
|
||||
stroke: stroke,
|
||||
fill: 'none',
|
||||
strokeDashArray: strokeDashArray,
|
||||
});
|
||||
var attrs = __assign(__assign(__assign({ d: d, style: isAnimation ? animationStyle : {} }, style), arrowConfig), { fill: 'none' });
|
||||
return core_1.h('path', __assign({ d: d }, attrs));
|
||||
};
|
||||
CurvedEdgeView.extendKey = 'curvedEdge';
|
||||
return CurvedEdgeView;
|
||||
return CurvedEdge;
|
||||
}(core_1.PolylineEdge));
|
||||
exports.CurvedEdge = CurvedEdge;
|
||||
var CurvedEdgeModel = /** @class */ (function (_super) {
|
||||
__extends(CurvedEdgeModel, _super);
|
||||
function CurvedEdgeModel() {
|
||||
@@ -91,20 +114,4 @@ var CurvedEdgeModel = /** @class */ (function (_super) {
|
||||
}
|
||||
return CurvedEdgeModel;
|
||||
}(core_1.PolylineEdgeModel));
|
||||
var CurvedEdge = {
|
||||
pluginName: 'curved-edge',
|
||||
curvedSpace: 5,
|
||||
init: function (_a) {
|
||||
var curvedSpace = _a.curvedSpace;
|
||||
CurvedEdge.curvedSpace = curvedSpace;
|
||||
},
|
||||
install: function (lf) {
|
||||
lf.register({
|
||||
type: 'curved-edge',
|
||||
view: CurvedEdgeView,
|
||||
model: CurvedEdgeModel,
|
||||
});
|
||||
},
|
||||
};
|
||||
exports.CurvedEdge = CurvedEdge;
|
||||
exports.default = CurvedEdge;
|
||||
exports.CurvedEdgeModel = CurvedEdgeModel;
|
||||
Reference in new issue
Block a user