dcim-topology2d 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chart-diagram/src/echarts/index.js +6 -3
- package/chart-diagram/src/utils/conversion.d.ts +1 -1
- package/chart-diagram/src/utils/conversion.js +6 -5
- package/core/src/common.js +11 -10
- package/core/src/core.js +15 -1
- package/core/src/element/common.js +12 -3
- package/core/src/element/datePicker.js +13 -16
- package/core/src/element/select.d.ts +1 -1
- package/core/src/element/select.js +1 -3
- package/core/src/element/tab.js +3 -8
- package/core/src/healps/changeData.js +61 -41
- package/core/src/middles/default.js +47 -43
- package/core/src/middles/nodes/formDatePicker.js +53 -12
- package/core/src/middles/nodes/formselect.js +14 -5
- package/core/src/middles/nodes/index.d.ts +2 -1
- package/core/src/middles/nodes/index.js +1 -0
- package/core/src/middles/nodes/switchs.d.ts +2 -0
- package/core/src/middles/nodes/switchs.js +46 -0
- package/core/src/models/line.js +7 -7
- package/core/src/models/node.js +83 -81
- package/core/src/models/pen.js +11 -11
- package/core/src/offscreen.js +19 -19
- package/core/src/preview.js +16 -7
- package/core/src/store/data.d.ts +2 -0
- package/core/src/store/data.js +6 -0
- package/core/src/utils/assignment.js +33 -2
- package/core/src/utils/construction.d.ts +24 -0
- package/core/src/utils/construction.js +22 -1
- package/core/src/utils/conversion.d.ts +2 -0
- package/core/src/utils/conversion.js +109 -0
- package/core/src/utils/math.d.ts +0 -1
- package/core/src/utils/math.js +0 -3
- package/core/src/utils/onmousevent.js +1 -1
- package/core/src/utils/params.d.ts +1 -0
- package/core/src/utils/params.js +75 -4
- package/package.json +1 -1
- package/store/default.js +22 -0
- package/store/index.js +2 -1
@@ -1,11 +1,12 @@
|
|
1
|
-
import {Store} from
|
1
|
+
import {Store} from "le5le-store";
|
2
2
|
import {rectangle} from './rectangle';
|
3
3
|
import { createDatePickerElement, loadJS, setDataPickerElementStyle } from '../../element';
|
4
|
-
import { s8 } from '../../utils';
|
4
|
+
import { s8, datePickerValueFormatting } from '../../utils';
|
5
5
|
import {commonStore} from "../../store";
|
6
|
+
import {datePickerType} from "../../../../store";
|
6
7
|
|
7
8
|
export async function fromDatePicker(ctx, node) {
|
8
|
-
// 绘制一个底图,类似于占位符。
|
9
|
+
// 绘制一个底图,类似于占位符。
|
9
10
|
rectangle(ctx, node);
|
10
11
|
|
11
12
|
if (!window.datePickerRegister) {
|
@@ -21,12 +22,35 @@ export async function fromDatePicker(ctx, node) {
|
|
21
22
|
if (!currentStore.pickerDataPool[node.id]) {
|
22
23
|
// 未创建该元件
|
23
24
|
node.elementId = s8();
|
25
|
+
|
26
|
+
if(currentStore.mqttParams.dataConfig.picker){
|
27
|
+
// 日期元件关联绑定的元件数据
|
28
|
+
const pickerConfig = currentStore.mqttParams.dataConfig.picker;
|
29
|
+
for (let [key, config] of pickerConfig.entries()){
|
30
|
+
if(config.dateId === node.id) {
|
31
|
+
node.formData.realIds = node.formData.realIds ? `${node.formData.realIds},${key}` : key;
|
32
|
+
node.formData.selected = config.dateStr;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
const format = node.pickerOptions.format;
|
38
|
+
const valueType = node.formData.valueType;
|
39
|
+
const dateType = node.pickerOptions.type;
|
40
|
+
node.pickerOptions.value = node.formData.selected || datePickerValueFormatting({
|
41
|
+
formatType: format,
|
42
|
+
valueType
|
43
|
+
}).dateStr;
|
24
44
|
const datePicker = createDatePickerElement(node);
|
25
45
|
currentStore.pickerDataPool[node.id] = {
|
46
|
+
format,
|
47
|
+
valueType,
|
48
|
+
dateType,
|
26
49
|
dom: {
|
27
50
|
container: datePicker
|
28
51
|
}
|
29
|
-
}
|
52
|
+
};
|
53
|
+
|
30
54
|
document.body.appendChild(datePicker);
|
31
55
|
// 添加当前节点到div层
|
32
56
|
node.addToDiv();
|
@@ -38,27 +62,44 @@ export async function fromDatePicker(ctx, node) {
|
|
38
62
|
if(pickerOptions.min && isValidInteger(pickerOptions.min)) pickerOptions.min = Number(pickerOptions.min);
|
39
63
|
if(pickerOptions.max && isValidInteger(pickerOptions.max)) pickerOptions.max = Number(pickerOptions.max);
|
40
64
|
}
|
65
|
+
let layDatePicker = null;
|
41
66
|
pickerOptions.elem = `#picker${node.id}`;
|
42
67
|
pickerOptions.done = function (val, date) {
|
43
|
-
|
44
|
-
|
68
|
+
const { year, month, hours, minutes, seconds } = date;
|
69
|
+
const map = {
|
70
|
+
yyyy: year,
|
71
|
+
MM: String(month).padStart(2, '0'),
|
72
|
+
dd: String(date.date).padStart(2, '0'),
|
73
|
+
HH: String(hours).padStart(2, '0'),
|
74
|
+
mm: String(minutes).padStart(2, '0'),
|
75
|
+
ss: String(seconds).padStart(2, '0')
|
76
|
+
};
|
77
|
+
node.formData.selected = val;
|
78
|
+
date.valueStr = val;
|
79
|
+
date.value = datePickerType[layDatePicker.config.type].replace(/yyyy|MM|dd|HH|mm|ss/g, match => map[match]);
|
45
80
|
Store.set(`${node.TID}-EVENT:change`, {node, date});
|
46
81
|
}
|
47
82
|
setTimeout(() => {
|
48
83
|
|
49
|
-
laydate.render(pickerOptions);
|
84
|
+
layDatePicker = laydate.render(pickerOptions);
|
50
85
|
|
51
86
|
}, 100)
|
52
87
|
}else {
|
53
88
|
if(node.formData.resetStyle) {
|
89
|
+
// 重置样式
|
54
90
|
setDataPickerElementStyle(node);
|
55
91
|
node.formData.resetStyle = false;
|
56
92
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
93
|
+
if(node.formData.render) {
|
94
|
+
// 重置数据
|
95
|
+
node.formData.render = false;
|
96
|
+
const params = {
|
97
|
+
format: node.pickerOptions.format,
|
98
|
+
valueType: node.formData.valueType,
|
99
|
+
dateType: node.pickerOptions.type
|
100
|
+
};
|
101
|
+
Object.assign(currentStore.pickerDataPool[node.id], params);
|
102
|
+
}
|
62
103
|
}
|
63
104
|
}
|
64
105
|
function isValidInteger(str) {
|
@@ -15,8 +15,13 @@ export function formSelect(ctx, node) {
|
|
15
15
|
const currentStore = commonStore[node.TID];
|
16
16
|
node.elementId = s8();
|
17
17
|
node.dash = 4;
|
18
|
+
// 下拉切换类型
|
19
|
+
const selectedType = node.events && node.events.find((item) => {
|
20
|
+
return !!item.dcimStaticForType
|
21
|
+
});
|
18
22
|
currentStore.selectDataPool[node.id] = {
|
19
23
|
slideState: node.selectDropdown,
|
24
|
+
staticType: selectedType,
|
20
25
|
node: {
|
21
26
|
id: node.id,
|
22
27
|
color: node.font.color,
|
@@ -35,26 +40,30 @@ export function formSelect(ctx, node) {
|
|
35
40
|
// 去空格重新赋值
|
36
41
|
node.formData.bindBlockTag = node.formData.bindBlockTag.trim();
|
37
42
|
}
|
43
|
+
|
38
44
|
let selectRealData = bindBlockId && currentStore.selectRealDataPool[bindBlockId];
|
39
|
-
if(
|
40
|
-
// select与echarts互相关联
|
45
|
+
if(selectRealData) {
|
46
|
+
// 数据统计之 select与echarts互相关联
|
41
47
|
if(node.formData.ids) {
|
48
|
+
// 显示隐藏类型下的数据统计,下拉节点数据处理
|
42
49
|
const optionIds = node.formData.ids.split(',');
|
43
50
|
for (let i = 0; i < optionIds.length; i++) {
|
44
51
|
if(selectRealData[i]) selectRealData[i].optionId = optionIds[i];
|
45
52
|
}
|
46
53
|
}
|
47
|
-
currentStore.selectDataPool[node.id]
|
48
|
-
|
54
|
+
const selectData = currentStore.selectDataPool[node.id];
|
55
|
+
selectData.data = selectRealData;
|
56
|
+
selectData.node.selected ? selectData.node.selected.id = selectRealData[0].id : selectData.node.selected = { id: selectRealData[0].id };
|
49
57
|
const echartsData = currentStore.echartsDataPool[bindBlockId];
|
50
58
|
echartsData ? echartsData.bindId = node.id : currentStore.echartsDataPool[bindBlockId] = {
|
51
59
|
bindId: node.id
|
52
60
|
};
|
53
|
-
// select与Tab
|
61
|
+
// select与Tab关联,主要用于下拉切换时当前画面绑定了tab切换的情况
|
54
62
|
const bindBlockTagData = currentStore.switchTabDataPool[`${node.formData.bindBlockTag}Data`];
|
55
63
|
if(bindBlockTagData) currentStore.echartsDataPool[bindBlockId].tabCorrelationType = 'select';
|
56
64
|
}else {
|
57
65
|
if(node.formData.ids) {
|
66
|
+
// 下拉显示隐藏
|
58
67
|
const optionIds = node.formData.ids.split(',');
|
59
68
|
const optionNames = node.formData.names.split(',');
|
60
69
|
const optionsData = [];
|
@@ -0,0 +1,46 @@
|
|
1
|
+
export function switchs(ctx, node) {
|
2
|
+
|
3
|
+
let x = node.rect.x;
|
4
|
+
let y = node.rect.y;
|
5
|
+
let width = node.rect.width;
|
6
|
+
let height = node.rect.height;
|
7
|
+
// 绘制圆角
|
8
|
+
var wr = node.borderRadius;
|
9
|
+
var hr = node.borderRadius;
|
10
|
+
if (node.borderRadius < 1) {
|
11
|
+
wr = node.rect.width * node.borderRadius;
|
12
|
+
hr = node.rect.height * node.borderRadius;
|
13
|
+
}
|
14
|
+
var r = wr < hr ? wr : hr;
|
15
|
+
if (node.rect.width < 2 * r) {
|
16
|
+
r = node.rect.width / 2;
|
17
|
+
}
|
18
|
+
if (node.rect.height < 2 * r) {
|
19
|
+
r = node.rect.height / 2;
|
20
|
+
}
|
21
|
+
//绘制椭圆
|
22
|
+
ctx.fillStyle = node.fillStyle;
|
23
|
+
ctx.beginPath();
|
24
|
+
ctx.moveTo(x + r, y);
|
25
|
+
ctx.lineTo(x + width - r, y);
|
26
|
+
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
|
27
|
+
ctx.lineTo(x + width, y + height - r);
|
28
|
+
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
|
29
|
+
ctx.lineTo(x + r, y + height);
|
30
|
+
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
|
31
|
+
ctx.lineTo(x, y + r);
|
32
|
+
ctx.quadraticCurveTo(x, y, x + r, y);
|
33
|
+
ctx.lineTo(x + width - r, y);
|
34
|
+
ctx.closePath();
|
35
|
+
node.fillStyle && ctx.fill();
|
36
|
+
ctx.stroke();
|
37
|
+
|
38
|
+
//绘制左侧 小圆 默认在右侧 isOpen:true
|
39
|
+
ctx.beginPath();
|
40
|
+
let cx = node.isOpen ? x + width - height * 0.5 : x + height * 0.5;
|
41
|
+
ctx.ellipse(cx, y + height * 0.5, height / 2 * 0.8, height / 2 * 0.8, 0, 0, Math.PI * 2);
|
42
|
+
ctx.fillStyle = '#ffffff';
|
43
|
+
ctx.closePath();
|
44
|
+
ctx.fill();
|
45
|
+
ctx.stroke();
|
46
|
+
}
|
package/core/src/models/line.js
CHANGED
@@ -417,19 +417,19 @@ var Line = /** @class */ (function (_super) {
|
|
417
417
|
}
|
418
418
|
Store.set(this.generateStoreKey('pts-') + this.id, null);
|
419
419
|
};
|
420
|
-
Line.prototype.scale = function (scale, center) {
|
421
|
-
this.from.x = center.x - (center.x - this.from.x) *
|
422
|
-
this.from.y = center.y - (center.y - this.from.y) *
|
423
|
-
this.to.x = center.x - (center.x - this.to.x) *
|
424
|
-
this.to.y = center.y - (center.y - this.to.y) *
|
420
|
+
Line.prototype.scale = function (scale, center, w, h) {
|
421
|
+
this.from.x = center.x - (center.x - this.from.x) * w;
|
422
|
+
this.from.y = center.y - (center.y - this.from.y) * h;
|
423
|
+
this.to.x = center.x - (center.x - this.to.x) * w;
|
424
|
+
this.to.y = center.y - (center.y - this.to.y) * h;
|
425
425
|
if (this.text && this.font && this.font.fontSize) {
|
426
426
|
this.font.fontSize *= scale;
|
427
427
|
this.textRect = null;
|
428
428
|
}
|
429
429
|
for (var _i = 0, _a = this.controlPoints; _i < _a.length; _i++) {
|
430
430
|
var pt = _a[_i];
|
431
|
-
pt.x = center.x - (center.x - pt.x) *
|
432
|
-
pt.y = center.y - (center.y - pt.y) *
|
431
|
+
pt.x = center.x - (center.x - pt.x) * w;
|
432
|
+
pt.y = center.y - (center.y - pt.y) * h;
|
433
433
|
}
|
434
434
|
Store.set(this.generateStoreKey('pts-') + this.id, null);
|
435
435
|
};
|
package/core/src/models/node.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
var __extends = (this && this.__extends) || (function () {
|
2
2
|
var extendStatics = function (d, b) {
|
3
3
|
extendStatics = Object.setPrototypeOf ||
|
4
|
-
|
5
|
-
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6
6
|
return extendStatics(d, b);
|
7
7
|
};
|
8
8
|
return function (d, b) {
|
@@ -35,6 +35,7 @@ var Node = /** @class */ (function (_super) {
|
|
35
35
|
_this.rotatedAnchors = [];
|
36
36
|
_this.animateDuration = 0;
|
37
37
|
_this.animateFrames = [];
|
38
|
+
_this.attribute = json.attribute || 'default';
|
38
39
|
_this.type = PenType.Node;
|
39
40
|
_this.TID = json.TID;
|
40
41
|
_this.selectDropdown = json.selectDropdown || false;
|
@@ -133,10 +134,10 @@ var Node = /** @class */ (function (_super) {
|
|
133
134
|
_this.animateDuration = json.animateDuration;
|
134
135
|
}
|
135
136
|
_this.animateType = json.animateType
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
? json.animateType
|
138
|
+
: json.animateDuration
|
139
|
+
? 'custom'
|
140
|
+
: '';
|
140
141
|
_this.animateAlone = json.animateAlone;
|
141
142
|
_this.iframe = json.iframe;
|
142
143
|
_this.iframePageAuto = json.iframePageAuto || false;
|
@@ -146,17 +147,18 @@ var Node = /** @class */ (function (_super) {
|
|
146
147
|
_this.play = json.play;
|
147
148
|
_this.nextPlay = json.nextPlay;
|
148
149
|
_this.time = json.time;
|
150
|
+
_this.isOpen = json.isOpen;
|
149
151
|
if (json.elementLoaded !== undefined) {
|
150
152
|
_this.elementId = null;
|
151
153
|
_this.elementLoaded = false;
|
152
154
|
}
|
153
|
-
if(this.name == 'arbitraryGraph') {
|
155
|
+
if (this.name == 'arbitraryGraph') {
|
154
156
|
this.rect.circles = json.rect.circles;
|
155
157
|
//let {x, y} = this.centroid(json.rect.circles);
|
156
|
-
let minX =
|
157
|
-
let minY = Math.min.apply(Math, json.rect.circles.map((item)=>{ return item.y}));
|
158
|
-
this.rect.x =
|
159
|
-
this.rect.y =
|
158
|
+
let minX = Math.min.apply(Math, json.rect.circles.map((item) => { return item.x }));
|
159
|
+
let minY = Math.min.apply(Math, json.rect.circles.map((item) => { return item.y }));
|
160
|
+
this.rect.x = minX;
|
161
|
+
this.rect.y = minY;
|
160
162
|
this.rect.ex = this.rect.x + this.rect.width;
|
161
163
|
this.rect.ey = this.rect.y + this.rect.height;
|
162
164
|
// this.rect.center.x = x;
|
@@ -164,8 +166,8 @@ var Node = /** @class */ (function (_super) {
|
|
164
166
|
// console.log('this.rect', this.rect);
|
165
167
|
// console.log('this---node---', this);
|
166
168
|
}
|
167
|
-
if(json.name === 'formTable') _this.setFormTableData(json);
|
168
|
-
if(json.name === 'tablePagination') _this.setTablePagination(json);
|
169
|
+
if (json.name === 'formTable') _this.setFormTableData(json);
|
170
|
+
if (json.name === 'tablePagination') _this.setTablePagination(json);
|
169
171
|
_this.init();
|
170
172
|
if (!noChild) {
|
171
173
|
_this.setChild(json.children);
|
@@ -174,13 +176,13 @@ var Node = /** @class */ (function (_super) {
|
|
174
176
|
_this.children = null;
|
175
177
|
}
|
176
178
|
|
177
|
-
if(json.name === 'time') {
|
178
|
-
_this.animateFn = function() {
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
179
|
+
if (json.name === 'time') {
|
180
|
+
_this.animateFn = function () {
|
181
|
+
let date = new Date();
|
182
|
+
var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
183
|
+
var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
184
|
+
var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
185
|
+
_this.time = { h: hour, m: minute, s: second }
|
184
186
|
}
|
185
187
|
}
|
186
188
|
|
@@ -212,7 +214,7 @@ var Node = /** @class */ (function (_super) {
|
|
212
214
|
this.addToDiv();
|
213
215
|
};
|
214
216
|
Node.prototype.setFormTableData = function (json) {
|
215
|
-
if(!Store.get('FORM:tableData')){
|
217
|
+
if (!Store.get('FORM:tableData')) {
|
216
218
|
Store.set('FORM:tableData', {
|
217
219
|
data: {
|
218
220
|
tableNodes: {},
|
@@ -227,18 +229,18 @@ var Node = /** @class */ (function (_super) {
|
|
227
229
|
data: tableData
|
228
230
|
})
|
229
231
|
const fromData = Store.get('SYNC:tableData');
|
230
|
-
if(fromData) {
|
231
|
-
if(!fromData[json.id].loading){
|
232
|
+
if (fromData) {
|
233
|
+
if (!fromData[json.id].loading) {
|
232
234
|
this.formData.tableBody = fromData[json.id].tableBody;
|
233
235
|
this.formData.total = fromData[json.id].total;
|
234
|
-
}else {
|
236
|
+
} else {
|
235
237
|
this.formData.tableBody = null;
|
236
238
|
this.formData.total = 0;
|
237
239
|
}
|
238
240
|
}
|
239
241
|
};
|
240
242
|
Node.prototype.setTablePagination = function (json) {
|
241
|
-
if(!Store.get('FORM:tableData')){
|
243
|
+
if (!Store.get('FORM:tableData')) {
|
242
244
|
Store.set('FORM:tableData', {
|
243
245
|
data: {
|
244
246
|
tableNodes: {},
|
@@ -250,7 +252,7 @@ var Node = /** @class */ (function (_super) {
|
|
250
252
|
const tableData = Store.get('FORM:tableData').data;
|
251
253
|
const fromData = Store.get('SYNC:tableData');
|
252
254
|
const tnode = fromData ? fromData[json.paginationData.bindFromTableId] : null;
|
253
|
-
if(tnode) json.paginationData.total = tnode.total;
|
255
|
+
if (tnode) json.paginationData.total = tnode.total;
|
254
256
|
tableData.paginationNodes[json.id] = json;
|
255
257
|
Store.set('FORM:tableData', {
|
256
258
|
data: tableData
|
@@ -258,8 +260,8 @@ var Node = /** @class */ (function (_super) {
|
|
258
260
|
};
|
259
261
|
Node.prototype.addToDiv = function () {
|
260
262
|
if (this.iframe ||
|
261
|
-
|
262
|
-
|
263
|
+
this.elementId ||
|
264
|
+
this.hasGif()) {
|
263
265
|
Store.set(this.generateStoreKey('LT:addDiv'), this);
|
264
266
|
}
|
265
267
|
};
|
@@ -335,13 +337,13 @@ var Node = /** @class */ (function (_super) {
|
|
335
337
|
this.drawBkRadialGradient(ctx);
|
336
338
|
break;
|
337
339
|
}
|
338
|
-
if(this.name === 'tablePagination') defaultText(ctx, this);
|
340
|
+
if (this.name === 'tablePagination') defaultText(ctx, this);
|
339
341
|
// Draw shape.
|
340
342
|
drawNodeFns[this.name](ctx, this);
|
341
343
|
// Draw text.
|
342
|
-
if(this.name === 'formTable') {
|
344
|
+
if (this.name === 'formTable') {
|
343
345
|
tableText(ctx, this);
|
344
|
-
}else {
|
346
|
+
} else {
|
345
347
|
if (this.name !== 'text' && this.text && !(this.image && this.floorImageIndex === true)) {
|
346
348
|
text(ctx, this);
|
347
349
|
}
|
@@ -436,14 +438,14 @@ var Node = /** @class */ (function (_super) {
|
|
436
438
|
img: img,
|
437
439
|
cnt: 1,
|
438
440
|
};
|
439
|
-
if(defaultImageNode) delete defaultImages[_this.id];
|
441
|
+
if (defaultImageNode) delete defaultImages[_this.id];
|
440
442
|
Store.set(_this.generateStoreKey('LT:imageLoaded'), true);
|
441
443
|
if (!_this.gif && gif) {
|
442
444
|
_this.gif = true;
|
443
445
|
Store.set(_this.generateStoreKey('LT:addDiv'), _this);
|
444
446
|
}
|
445
447
|
};
|
446
|
-
img.onerror = function(e){
|
448
|
+
img.onerror = function (e) {
|
447
449
|
// 图片加载失败时预留默认图为空
|
448
450
|
defaultImages[_this.id] = {
|
449
451
|
img: '',
|
@@ -451,7 +453,7 @@ var Node = /** @class */ (function (_super) {
|
|
451
453
|
};
|
452
454
|
};
|
453
455
|
};
|
454
|
-
Node.prototype.initDrawImg = function (ctx){
|
456
|
+
Node.prototype.initDrawImg = function (ctx) {
|
455
457
|
var _this = this;
|
456
458
|
ctx.save();
|
457
459
|
ctx.shadowColor = '';
|
@@ -509,7 +511,7 @@ var Node = /** @class */ (function (_super) {
|
|
509
511
|
y = rect.ey - h;
|
510
512
|
break;
|
511
513
|
}
|
512
|
-
if(!_this.activeImgeIndex) ctx.drawImage(this.img, x, y, w, h);
|
514
|
+
if (!_this.activeImgeIndex) ctx.drawImage(this.img, x, y, w, h);
|
513
515
|
ctx.restore();
|
514
516
|
};
|
515
517
|
Node.prototype.calcAnchors = function () {
|
@@ -554,21 +556,21 @@ var Node = /** @class */ (function (_super) {
|
|
554
556
|
var parentW = parent.rect.width - parent.paddingLeftNum - parent.paddingRightNum;
|
555
557
|
var parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum;
|
556
558
|
var x = parent.rect.x +
|
557
|
-
|
558
|
-
|
559
|
-
|
559
|
+
parent.paddingLeftNum +
|
560
|
+
abs(parentW, this.rectInParent.x) +
|
561
|
+
abs(parentW, this.rectInParent.marginLeft);
|
560
562
|
var y = parent.rect.y +
|
561
|
-
|
562
|
-
|
563
|
-
|
563
|
+
parent.paddingTopNum +
|
564
|
+
abs(parentH, this.rectInParent.y) +
|
565
|
+
abs(parentW, this.rectInParent.marginTop);
|
564
566
|
var w = abs(parentW, this.rectInParent.width);
|
565
567
|
var h = abs(parentH, this.rectInParent.height);
|
566
568
|
if (this.rectInParent.marginLeft === undefined &&
|
567
|
-
|
569
|
+
this.rectInParent.marginRight) {
|
568
570
|
x -= abs(parentW, this.rectInParent.marginRight);
|
569
571
|
}
|
570
572
|
if (this.rectInParent.marginTop === undefined &&
|
571
|
-
|
573
|
+
this.rectInParent.marginBottom) {
|
572
574
|
y -= abs(parentW, this.rectInParent.marginBottom);
|
573
575
|
}
|
574
576
|
this.rect = new Rect(x, y, w, h);
|
@@ -599,15 +601,15 @@ var Node = /** @class */ (function (_super) {
|
|
599
601
|
var parentH = parent.rect.height - parent.paddingTopNum - parent.paddingBottomNum;
|
600
602
|
this.rectInParent = {
|
601
603
|
x: ((this.rect.x - parent.rect.x - parent.paddingLeftNum) * 100) /
|
602
|
-
|
603
|
-
|
604
|
+
parentW +
|
605
|
+
'%',
|
604
606
|
y: ((this.rect.y - parent.rect.y - parent.paddingTopNum) * 100) / parentH +
|
605
|
-
|
607
|
+
'%',
|
606
608
|
width: (this.rect.width * 100) / parentW + '%',
|
607
609
|
height: (this.rect.height * 100) / parentH + '%',
|
608
610
|
rotate: this.rectInParent
|
609
|
-
|
610
|
-
|
611
|
+
? this.rectInParent.rotate || 0
|
612
|
+
: this.rotate || 0,
|
611
613
|
rect: this.rect.clone(),
|
612
614
|
};
|
613
615
|
};
|
@@ -628,7 +630,7 @@ var Node = /** @class */ (function (_super) {
|
|
628
630
|
var timeline = now - this.animateStart;
|
629
631
|
if (timeline > this.animateDuration) {
|
630
632
|
if (++this.animateCycleIndex >= this.animateCycle &&
|
631
|
-
|
633
|
+
this.animateCycle > 0) {
|
632
634
|
this.animateStart = 0;
|
633
635
|
this.animateCycleIndex = 0;
|
634
636
|
var item = this.animateFrames[this.animateFrames.length - 1];
|
@@ -668,78 +670,78 @@ var Node = /** @class */ (function (_super) {
|
|
668
670
|
var rate = (timeline - item.start) / item.duration;
|
669
671
|
if (item.linear) {
|
670
672
|
// 线条左右流动动画
|
671
|
-
if([animateType.LeftFlow, animateType.RightFlow].includes(this.animateType) && item.state.lineDashOffset){
|
673
|
+
if ([animateType.LeftFlow, animateType.RightFlow].includes(this.animateType) && item.state.lineDashOffset) {
|
672
674
|
let o = item.state.lineDashOffset;
|
673
675
|
switch (this.animateType) {
|
674
676
|
case animateType.LeftFlow:
|
675
677
|
o = Math.abs(o)
|
676
678
|
if (o > 100) o = 1;
|
677
|
-
o++
|
678
|
-
|
679
|
+
o++
|
680
|
+
|
679
681
|
break;
|
680
682
|
case animateType.RightFlow:
|
681
|
-
o = Math.abs(o)
|
683
|
+
o = Math.abs(o) * -1
|
682
684
|
if (o < -100) o = -1;
|
683
685
|
o--
|
684
686
|
break;
|
685
687
|
}
|
686
688
|
item.state.lineDashOffset = o
|
687
689
|
this.lineDashOffset = item.state.lineDashOffset;
|
688
|
-
}else if(([animateType.Show, animateType.Rotate].includes(this.animateType) || this.name === 'electricFan') && item.state.rotate !== item.initState.rotate) {
|
690
|
+
} else if (([animateType.Show, animateType.Rotate].includes(this.animateType) || this.name === 'electricFan') && item.state.rotate !== item.initState.rotate) {
|
689
691
|
// 旋转动画,判断逻辑先这么写,日后将所有动画统一在编辑器中配置,再做优化
|
690
692
|
this.rotate =
|
691
|
-
|
692
|
-
|
693
|
+
item.initState.rotate +
|
694
|
+
(item.state.rotate - item.initState.rotate) * rate;
|
693
695
|
rectChanged = true;
|
694
|
-
}else {
|
696
|
+
} else {
|
695
697
|
|
696
698
|
if (item.state.rect.x !== item.initState.rect.x) {
|
697
699
|
this.rect.x =
|
698
|
-
|
699
|
-
|
700
|
+
item.initState.rect.x +
|
701
|
+
(item.state.rect.x - item.initState.rect.x) * rate;
|
700
702
|
rectChanged = true;
|
701
703
|
}
|
702
704
|
if (item.state.rect.y !== item.initState.rect.y) {
|
703
705
|
this.rect.y =
|
704
|
-
|
705
|
-
|
706
|
+
item.initState.rect.y +
|
707
|
+
(item.state.rect.y - item.initState.rect.y) * rate;
|
706
708
|
rectChanged = true;
|
707
709
|
}
|
708
710
|
if (item.state.rect.width !== item.initState.rect.width) {
|
709
711
|
this.rect.width =
|
710
|
-
|
711
|
-
|
712
|
+
item.initState.rect.width +
|
713
|
+
(item.state.rect.width - item.initState.rect.width) * rate;
|
712
714
|
rectChanged = true;
|
713
715
|
}
|
714
716
|
if (item.state.rect.height !== item.initState.rect.height) {
|
715
717
|
this.rect.height =
|
716
|
-
|
717
|
-
|
718
|
+
item.initState.rect.height +
|
719
|
+
(item.state.rect.height - item.initState.rect.height) * rate;
|
718
720
|
rectChanged = true;
|
719
721
|
}
|
720
722
|
this.rect.ex = this.rect.x + this.rect.width;
|
721
723
|
this.rect.ey = this.rect.y + this.rect.height;
|
722
724
|
this.rect.calcCenter();
|
723
725
|
if (item.initState.z !== undefined &&
|
724
|
-
|
726
|
+
item.state.z !== item.initState.z) {
|
725
727
|
this.z =
|
726
|
-
|
728
|
+
item.initState.z + (item.state.z - item.initState.z) * rate;
|
727
729
|
rectChanged = true;
|
728
730
|
}
|
729
731
|
if (item.state.borderRadius !== item.initState.borderRadius) {
|
730
732
|
this.borderRadius =
|
731
|
-
|
732
|
-
|
733
|
+
item.initState.borderRadius +
|
734
|
+
(item.state.borderRadius - item.initState.borderRadius) * rate;
|
733
735
|
}
|
734
736
|
if (item.state.lineWidth !== item.initState.lineWidth) {
|
735
737
|
this.lineWidth =
|
736
|
-
|
737
|
-
|
738
|
+
item.initState.lineWidth +
|
739
|
+
(item.state.lineWidth - item.initState.lineWidth) * rate;
|
738
740
|
}
|
739
741
|
if (item.state.globalAlpha !== item.initState.globalAlpha) {
|
740
742
|
this.globalAlpha =
|
741
|
-
|
742
|
-
|
743
|
+
item.initState.globalAlpha +
|
744
|
+
(item.state.globalAlpha - item.initState.globalAlpha) * rate;
|
743
745
|
}
|
744
746
|
}
|
745
747
|
}
|
@@ -770,14 +772,14 @@ var Node = /** @class */ (function (_super) {
|
|
770
772
|
h = scale;
|
771
773
|
}
|
772
774
|
this['oldRect'] = this.rect.clone();
|
773
|
-
if(this.rect.circles) {
|
774
|
-
for(let c=0, circles= this.rect.circles; c<circles.length; c++) {
|
775
|
+
if (this.rect.circles) {
|
776
|
+
for (let c = 0, circles = this.rect.circles; c < circles.length; c++) {
|
775
777
|
circles[c].x = center.x - (center.x - circles[c].x) * w;
|
776
778
|
circles[c].y = center.y - (center.y - circles[c].y) * h;
|
777
779
|
}
|
778
780
|
}
|
779
781
|
this.rect.x = center.x - (center.x - this.rect.x) * w;
|
780
|
-
if(this.rotate % 180) {
|
782
|
+
if (this.rotate % 180) {
|
781
783
|
this.rect.x = this.rect.x + (this.rect.width * w - this.rect.width * h) / 2;
|
782
784
|
}
|
783
785
|
this.rect.y = center.y - (center.y - this.rect.y) * h;
|
@@ -786,7 +788,7 @@ var Node = /** @class */ (function (_super) {
|
|
786
788
|
this.rect.ex = this.rect.x + this.rect.width;
|
787
789
|
this.rect.ey = this.rect.y + this.rect.height;
|
788
790
|
this.z *= scale;
|
789
|
-
if(!(center.type && center.type === 'bottLogo')) {
|
791
|
+
if (!(center.type && center.type === 'bottLogo')) {
|
790
792
|
if (this.imageWidth) {
|
791
793
|
this.imageWidth *= w;
|
792
794
|
}
|
@@ -890,8 +892,8 @@ var Node = /** @class */ (function (_super) {
|
|
890
892
|
}
|
891
893
|
};
|
892
894
|
Node.prototype.translate = function (x, y) {
|
893
|
-
if(this.rect.circles) {
|
894
|
-
for(let c=0, circles= this.rect.circles; c<circles.length; c++) {
|
895
|
+
if (this.rect.circles) {
|
896
|
+
for (let c = 0, circles = this.rect.circles; c < circles.length; c++) {
|
895
897
|
circles[c].x += x;
|
896
898
|
circles[c].y += y;
|
897
899
|
}
|
@@ -948,7 +950,7 @@ var Node = /** @class */ (function (_super) {
|
|
948
950
|
return n;
|
949
951
|
};
|
950
952
|
//新增属性
|
951
|
-
Node.prototype.area = function(pts) {
|
953
|
+
Node.prototype.area = function (pts) {
|
952
954
|
var area = 0;
|
953
955
|
var pts = pts;
|
954
956
|
var nPts = pts.length;
|
@@ -964,7 +966,7 @@ var Node = /** @class */ (function (_super) {
|
|
964
966
|
area /= 2;
|
965
967
|
return area;
|
966
968
|
};
|
967
|
-
Node.prototype.centroid = function(pts) {
|
969
|
+
Node.prototype.centroid = function (pts) {
|
968
970
|
var pts = pts;
|
969
971
|
var nPts = pts.length;
|
970
972
|
var x = 0;
|