dcim-topology2d 1.1.6 → 2.0.5
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/index.d.ts +1 -1
- package/chart-diagram/index.js +1 -1
- package/chart-diagram/src/echarts/index.js +88 -96
- package/chart-diagram/src/register.js +3 -3
- package/chart-diagram/src/utils/changeOptions.d.ts +7 -4
- package/chart-diagram/src/utils/changeOptions.js +228 -144
- package/chart-diagram/src/utils/conversion.d.ts +12 -12
- package/chart-diagram/src/utils/conversion.js +263 -137
- package/chart-diagram/src/utils/render.d.ts +6 -0
- package/chart-diagram/src/utils/render.js +124 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/src/activeLayer.js +0 -6
- package/core/src/canvas.js +1 -0
- package/core/src/common.d.ts +1 -2
- package/core/src/common.js +197 -541
- package/core/src/core.js +116 -60
- package/core/src/divLayer.d.ts +0 -3
- package/core/src/divLayer.js +13 -34
- package/core/src/element/common.d.ts +5 -0
- package/core/src/element/common.js +52 -0
- package/core/src/element/iframe.d.ts +3 -0
- package/core/src/element/iframe.js +12 -0
- package/core/src/element/index.d.ts +4 -0
- package/core/src/element/index.js +4 -0
- package/core/src/element/select.d.ts +11 -0
- package/core/src/element/select.js +234 -0
- package/core/src/element/tab.d.ts +1 -0
- package/core/src/element/tab.js +19 -0
- package/core/src/healps/changeData.d.ts +1 -2
- package/core/src/healps/changeData.js +33 -125
- package/core/src/middles/default.js +3 -1
- package/core/src/middles/nodes/arbitrarygraph.js +11 -9
- package/core/src/middles/nodes/formselect.d.ts +2 -0
- package/core/src/middles/nodes/formselect.js +87 -0
- package/core/src/middles/nodes/iframe.js +21 -4
- package/core/src/middles/nodes/index.d.ts +1 -0
- package/core/src/middles/nodes/index.js +1 -0
- package/core/src/models/node.d.ts +4 -0
- package/core/src/models/node.js +24 -22
- package/core/src/models/pen.js +3 -52
- package/core/src/models/rect.js +2 -2
- package/core/src/options.d.ts +2 -0
- package/core/src/options.js +2 -1
- package/core/src/preview.js +51 -32
- package/core/src/renderLayer.d.ts +10 -6
- package/core/src/renderLayer.js +36 -43
- package/core/src/store/data.d.ts +71 -21
- package/core/src/store/data.js +93 -17
- package/core/src/utils/assignment.d.ts +6 -3
- package/core/src/utils/assignment.js +120 -21
- package/core/src/utils/construction.d.ts +10 -3
- package/core/src/utils/construction.js +7 -1
- package/core/src/utils/conversion.d.ts +3 -0
- package/core/src/utils/conversion.js +62 -1
- package/core/src/utils/index.d.ts +1 -1
- package/core/src/utils/index.js +1 -1
- package/core/src/utils/math.d.ts +1 -0
- package/core/src/utils/math.js +3 -0
- package/core/src/utils/onmousevent.d.ts +3 -0
- package/core/src/utils/onmousevent.js +27 -7
- package/core/src/utils/params.d.ts +2 -0
- package/core/src/utils/params.js +57 -0
- package/myShape-diagram/index.js +196 -0
- package/package.json +1 -1
- package/static/echartsDefaultData.js +27 -107
- package/static/element.js +14 -0
- package/static/form.js +11 -0
- package/static/index.js +2 -1
- package/store/actions.js +1 -0
- package/store/clear.js +10 -0
- package/store/index.js +2 -0
- package/style/common.css +18 -0
- package/style/editor.css +13 -0
- package/style/index.css +3 -12
- package/style/select.css +143 -0
- package/core/src/poll.js +0 -37
- package/core/src/utils/dom.d.ts +0 -9
- package/core/src/utils/dom.js +0 -103
- package/core/src/utils/dom.js.map +0 -1
- package/myShape-diagram/myShape.js +0 -196
- package/static/echartsStore.js +0 -14
- /package/myShape-diagram/{myShape.ts → index.ts} +0 -0
package/core/src/models/node.js
CHANGED
@@ -20,7 +20,7 @@ import { defaultAnchors } from '../middles/default.anchor';
|
|
20
20
|
import { defaultIconRect, defaultTextRect } from '../middles/default.rect';
|
21
21
|
import { text, tableText, defaultText, iconfont } from '../middles/nodes/text';
|
22
22
|
import { Store } from 'le5le-store';
|
23
|
-
import { abs, s8, animateType
|
23
|
+
import { abs, s8, animateType } from '../utils';
|
24
24
|
export const images = {};
|
25
25
|
export const defaultImages = {};
|
26
26
|
var Node = /** @class */ (function (_super) {
|
@@ -37,8 +37,10 @@ var Node = /** @class */ (function (_super) {
|
|
37
37
|
_this.animateFrames = [];
|
38
38
|
_this.type = PenType.Node;
|
39
39
|
_this.TID = json.TID;
|
40
|
+
_this.selectDropdown = json.selectDropdown || false;
|
40
41
|
_this.is3D = json.is3D;
|
41
42
|
_this.z = json.z;
|
43
|
+
_this.order = json.order;
|
42
44
|
_this.zRotate = json.zRotate || 0;
|
43
45
|
_this.borderRadius = +json.borderRadius || 0;
|
44
46
|
_this.icon = json.icon;
|
@@ -81,7 +83,7 @@ var Node = /** @class */ (function (_super) {
|
|
81
83
|
_this.leakageEnd = json.leakageEnd || 0;
|
82
84
|
_this.leakageFillStyle = json.leakageFillStyle || '#ff0000';
|
83
85
|
_this.bindStaticId = json.bindStaticId || '';
|
84
|
-
_this.buttonCheckSlide = json.buttonCheckSlide || '';
|
86
|
+
//_this.buttonCheckSlide = json.buttonCheckSlide || '';
|
85
87
|
_this.visitStrokeStyle = json.visitStrokeStyle || '';
|
86
88
|
_this.thBottomStrokeStyle = json.thBottomStrokeStyle || '#fff';
|
87
89
|
_this.thBottomLineWidth = json.thBottomLineWidth || 1;
|
@@ -235,17 +237,11 @@ var Node = /** @class */ (function (_super) {
|
|
235
237
|
data: tableData
|
236
238
|
})
|
237
239
|
};
|
238
|
-
Node.prototype.addToDiv = function (
|
240
|
+
Node.prototype.addToDiv = function () {
|
239
241
|
if (this.iframe ||
|
240
242
|
this.elementId ||
|
241
243
|
this.hasGif()) {
|
242
244
|
Store.set(this.generateStoreKey('LT:addDiv'), this);
|
243
|
-
// if(type || this.iframe) {
|
244
|
-
// // 复合Echarts初始化
|
245
|
-
// createChildrenDivByElementId(this);
|
246
|
-
// }else {
|
247
|
-
// Store.set(this.generateStoreKey('LT:addDiv'), this);
|
248
|
-
// }
|
249
245
|
}
|
250
246
|
};
|
251
247
|
Node.prototype.hasGif = function () {
|
@@ -275,6 +271,7 @@ var Node = /** @class */ (function (_super) {
|
|
275
271
|
this.children = [];
|
276
272
|
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
|
277
273
|
var item = children_1[_i];
|
274
|
+
item.visible = this.visible;
|
278
275
|
var child = void 0;
|
279
276
|
switch (item.type) {
|
280
277
|
case PenType.Line:
|
@@ -620,8 +617,8 @@ var Node = /** @class */ (function (_super) {
|
|
620
617
|
this.dash = item.state.dash;
|
621
618
|
this.strokeStyle = item.state.strokeStyle;
|
622
619
|
this.fillStyle = item.state.fillStyle;
|
623
|
-
this.text = item.state.text;
|
624
|
-
this.font = item.state.font;
|
620
|
+
//this.text = item.state.text;
|
621
|
+
//this.font = item.state.font;
|
625
622
|
this.lineWidth = item.state.lineWidth;
|
626
623
|
this.rotate = item.state.rotate;
|
627
624
|
this.globalAlpha = item.state.globalAlpha;
|
@@ -647,8 +644,8 @@ var Node = /** @class */ (function (_super) {
|
|
647
644
|
this.dash = item.state.dash;
|
648
645
|
this.strokeStyle = item.state.strokeStyle;
|
649
646
|
this.fillStyle = item.state.fillStyle;
|
650
|
-
this.text = item.state.text;
|
651
|
-
this.font = item.state.font;
|
647
|
+
//this.text = item.state.text;
|
648
|
+
//this.font = item.state.font;
|
652
649
|
var rate = (timeline - item.start) / item.duration;
|
653
650
|
if (item.linear) {
|
654
651
|
// 线条左右流动动画
|
@@ -745,21 +742,20 @@ var Node = /** @class */ (function (_super) {
|
|
745
742
|
this['oldRect'] = this.rect.clone();
|
746
743
|
if(this.rect.circles) {
|
747
744
|
for(let c=0, circles= this.rect.circles; c<circles.length; c++) {
|
748
|
-
circles[c].x =
|
749
|
-
circles[c].y =
|
745
|
+
circles[c].x = center.x - (center.x - circles[c].x) * w;
|
746
|
+
circles[c].y = center.y - (center.y - circles[c].y) * h;
|
750
747
|
}
|
751
|
-
}else {
|
752
|
-
this.rect.x = center.x - (center.x - this.rect.x) * w;
|
753
|
-
if(this.rotate % 180) {
|
754
|
-
this.rect.x = this.rect.x + (this.rect.width * w - this.rect.width * h) / 2;
|
755
|
-
}
|
756
|
-
this.rect.y = center.y - (center.y - this.rect.y) * h;
|
757
748
|
}
|
758
|
-
this.
|
749
|
+
this.rect.x = center.x - (center.x - this.rect.x) * w;
|
750
|
+
if(this.rotate % 180) {
|
751
|
+
this.rect.x = this.rect.x + (this.rect.width * w - this.rect.width * h) / 2;
|
752
|
+
}
|
753
|
+
this.rect.y = center.y - (center.y - this.rect.y) * h;
|
759
754
|
this.rect.width *= this.rotate % 180 ? h : w;
|
760
755
|
this.rect.height *= h;
|
761
756
|
this.rect.ex = this.rect.x + this.rect.width;
|
762
757
|
this.rect.ey = this.rect.y + this.rect.height;
|
758
|
+
this.z *= scale;
|
763
759
|
if(!(center.type && center.type === 'bottLogo')) {
|
764
760
|
if (this.imageWidth) {
|
765
761
|
this.imageWidth *= w;
|
@@ -864,6 +860,12 @@ var Node = /** @class */ (function (_super) {
|
|
864
860
|
}
|
865
861
|
};
|
866
862
|
Node.prototype.translate = function (x, y) {
|
863
|
+
if(this.rect.circles) {
|
864
|
+
for(let c=0, circles= this.rect.circles; c<circles.length; c++) {
|
865
|
+
circles[c].x += x;
|
866
|
+
circles[c].y += y;
|
867
|
+
}
|
868
|
+
}
|
867
869
|
this.rect.x += x;
|
868
870
|
this.rect.y += y;
|
869
871
|
this.rect.ex = this.rect.x + this.rect.width;
|
package/core/src/models/pen.js
CHANGED
@@ -3,7 +3,6 @@ import { s8 } from '../utils/uuid';
|
|
3
3
|
import { Rect } from './rect';
|
4
4
|
import { pointInRect } from '../utils/canvas';
|
5
5
|
import { EventType, EventAction } from './event';
|
6
|
-
import { setConfItemNode } from '../healps/changeData';
|
7
6
|
export var PenType;
|
8
7
|
(function (PenType) {
|
9
8
|
PenType[PenType["Node"] = 0] = "Node";
|
@@ -24,7 +23,7 @@ var Pen = /** @class */ (function () {
|
|
24
23
|
this.font = {
|
25
24
|
color: '',
|
26
25
|
fontFamily: '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',
|
27
|
-
fontSize: 12,
|
26
|
+
fontSize: json.name === 'select' ? 14 : 12,
|
28
27
|
lineHeight: 1.5,
|
29
28
|
fontStyle: 'normal',
|
30
29
|
fontWeight: 'normal',
|
@@ -108,6 +107,7 @@ var Pen = /** @class */ (function () {
|
|
108
107
|
this.tipId = json.tipId;
|
109
108
|
this.title = json.title;
|
110
109
|
this.visible = json.visible !== false;
|
110
|
+
this.visibleSwitch = !!json.visibleSwitch; // 元件显示隐藏的开关量
|
111
111
|
this.defaultFillStyle = json.defaultFillStyle || '';
|
112
112
|
this.defaultFontColor = json.defaultFontColor || '';
|
113
113
|
this.defaultStrokeStyle = json.defaultStrokeStyle || '';
|
@@ -131,7 +131,7 @@ var Pen = /** @class */ (function () {
|
|
131
131
|
}
|
132
132
|
}
|
133
133
|
Pen.prototype.render = function (ctx) {
|
134
|
-
if (!this.visible && !
|
134
|
+
if (!this.visible && !this.visibleSwitch){
|
135
135
|
return;
|
136
136
|
}
|
137
137
|
if (this.from && !this.to) {
|
@@ -248,55 +248,6 @@ var Pen = /** @class */ (function () {
|
|
248
248
|
this[this.eventFns[item.action]] && this[this.eventFns[item.action]](item.value, item.params);
|
249
249
|
}
|
250
250
|
};
|
251
|
-
Pen.prototype.doSocketMqtt = function (item, msg, client) {
|
252
|
-
if (item.action < EventAction.Function) {
|
253
|
-
this[this.eventFns[item.action]](msg.value || msg || item.value, msg.params || item.params, client);
|
254
|
-
}
|
255
|
-
else if (item.action < EventAction.SetProps) {
|
256
|
-
if (item.action === EventAction.Function && item.value) return this[this.eventFns[item.action]](item.value, msg || item.params, client);
|
257
|
-
let jsonNode = msg;
|
258
|
-
if (typeof msg === 'string') {
|
259
|
-
try {
|
260
|
-
jsonNode = JSON.parse(msg);
|
261
|
-
}catch (error) { }
|
262
|
-
}
|
263
|
-
console.log('doSocketMqtt-------------', jsonNode)
|
264
|
-
Store.set('mqtt:responseData', jsonNode)
|
265
|
-
//const { areaData, assetData, data } = jsonNode
|
266
|
-
if (!this.data && this.data.length <= 0 && typeof this.data !== 'object') return
|
267
|
-
// const subscribeObj = {
|
268
|
-
// areaData, assetData, data,
|
269
|
-
// asset: ''
|
270
|
-
// }
|
271
|
-
jsonNode.asset = ''
|
272
|
-
Object.assign(this, setConfItemNode(this, jsonNode))
|
273
|
-
}
|
274
|
-
else if (item.action === EventAction.SetProps) {
|
275
|
-
var props = [];
|
276
|
-
var data = msg;
|
277
|
-
if (typeof msg === 'string') {
|
278
|
-
try {
|
279
|
-
data = JSON.parse(msg);
|
280
|
-
}
|
281
|
-
catch (error) { }
|
282
|
-
}
|
283
|
-
if (Array.isArray(data)) {
|
284
|
-
props = data;
|
285
|
-
}
|
286
|
-
for (var _i = 0, props_1 = props; _i < props_1.length; _i++) {
|
287
|
-
var prop = props_1[_i];
|
288
|
-
if (prop.key) {
|
289
|
-
if (typeof prop.value === 'object') {
|
290
|
-
this[prop.key] = Object.assign(this[prop.key], prop.value);
|
291
|
-
}
|
292
|
-
else {
|
293
|
-
this[prop.key] = prop.value;
|
294
|
-
}
|
295
|
-
}
|
296
|
-
}
|
297
|
-
Store.set(this.generateStoreKey('LT:render'), true);
|
298
|
-
}
|
299
|
-
};
|
300
251
|
Pen.prototype.show = function () {
|
301
252
|
this.visible = true;
|
302
253
|
return this;
|
package/core/src/models/rect.js
CHANGED
package/core/src/options.d.ts
CHANGED
@@ -11,6 +11,7 @@ export declare enum KeydownType {
|
|
11
11
|
Canvas = 1
|
12
12
|
}
|
13
13
|
export interface Options {
|
14
|
+
type?: string;
|
14
15
|
cacheLen?: number;
|
15
16
|
extDpiRatio?: number;
|
16
17
|
width?: string | number;
|
@@ -59,6 +60,7 @@ export interface Options {
|
|
59
60
|
keydown?: KeydownType;
|
60
61
|
viewPadding?: Padding;
|
61
62
|
on?: (event: string, data: any) => void;
|
63
|
+
storeSubscribe?: boolean
|
62
64
|
}
|
63
65
|
export declare const DefalutOptions: Options;
|
64
66
|
|
package/core/src/options.js
CHANGED
package/core/src/preview.js
CHANGED
@@ -14,7 +14,18 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
import {KeyType} from './options';
|
15
15
|
import {Point} from './models';
|
16
16
|
import { Common } from './common'
|
17
|
-
import {
|
17
|
+
import {
|
18
|
+
downDataType,
|
19
|
+
previewType,
|
20
|
+
formatPadding,
|
21
|
+
mousMoveFun,
|
22
|
+
mousDownFun,
|
23
|
+
omouseEventPrototDoWindowFn
|
24
|
+
} from './utils';
|
25
|
+
import {
|
26
|
+
resetSelectInteractiveState,
|
27
|
+
setSelectDropdownInteractiveState
|
28
|
+
} from './element';
|
18
29
|
|
19
30
|
var Preview = (function (_super) {
|
20
31
|
__extends(Preview, _super);
|
@@ -74,7 +85,8 @@ var Preview = (function (_super) {
|
|
74
85
|
if (_this.inputObj) {
|
75
86
|
_this.setNodeText();
|
76
87
|
}
|
77
|
-
|
88
|
+
resetSelectInteractiveState(_this.moveIn.hoverNode);
|
89
|
+
const {eventType, value, staticType} = mousDownFun(_this.store.options.type, _this.moveIn.eventNode);
|
78
90
|
if (_this.moveIn.type == _this.moveInType.Nodes) {
|
79
91
|
_this.setAttributeForCanvasPoint('pointer');
|
80
92
|
switch (eventType) {
|
@@ -91,10 +103,14 @@ var Preview = (function (_super) {
|
|
91
103
|
if (visibleRange == '1') {
|
92
104
|
_this.openCount++
|
93
105
|
}
|
106
|
+
this.render();
|
94
107
|
break;
|
95
108
|
case downDataType.Tabswitch:
|
96
109
|
_this.switchStaticsCheckType(_this.moveIn.hoverNode, _this.moveIn.eventNode);
|
97
110
|
break;
|
111
|
+
case downDataType.Formselect:
|
112
|
+
setSelectDropdownInteractiveState(_this.moveIn.hoverNode, staticType, previewType.Dcim);
|
113
|
+
break;
|
98
114
|
}
|
99
115
|
}
|
100
116
|
};
|
@@ -114,7 +130,7 @@ var Preview = (function (_super) {
|
|
114
130
|
_this.divLayer.canvas.onmousedown = this.onmousedown;
|
115
131
|
_this.divLayer.canvas.onmouseup = this.onmouseup;
|
116
132
|
_this.divLayer.canvas.onwheel = function (event) {
|
117
|
-
if (_this.store.options.disableScale) {
|
133
|
+
if (_this.store.options.disableScale || _this.store.options.type === 'dialog') {
|
118
134
|
return;
|
119
135
|
}
|
120
136
|
switch (_this.store.options.scaleKey) {
|
@@ -162,6 +178,14 @@ var Preview = (function (_super) {
|
|
162
178
|
_this.divLayer.canvas.focus();
|
163
179
|
return false;
|
164
180
|
};
|
181
|
+
window.onresize = function () {
|
182
|
+
const isFullScreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement;
|
183
|
+
if(!isFullScreen && _this.isFullScreen){
|
184
|
+
_this.moveIn.hoverNode.text = '全屏';
|
185
|
+
_this.fitViewPreview(_this.isFullScreen);
|
186
|
+
_this.isFullScreen = false;
|
187
|
+
}
|
188
|
+
};
|
165
189
|
return _this;
|
166
190
|
}
|
167
191
|
Preview.prototype.setAttributeForCanvasPoint = function (type){
|
@@ -175,43 +199,30 @@ var Preview = (function (_super) {
|
|
175
199
|
};
|
176
200
|
// open - redraw by the data
|
177
201
|
Preview.prototype.open = function (topoJSon, type) {
|
178
|
-
this.conversionData(topoJSon
|
202
|
+
this.conversionData(topoJSon);
|
179
203
|
this.setBKImageRect();
|
180
204
|
this.fitView();
|
181
205
|
this.render(true);
|
182
206
|
this.animate(true);
|
183
207
|
};
|
184
208
|
Preview.prototype.setBKImageRect = function () {
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
209
|
+
if (this.store.data.bkImageRect) {
|
210
|
+
this.store.data.bkImageRect.x = this.store.data.bkImageRect.x ? Number(this.store.data.bkImageRect.x) : 0;
|
211
|
+
this.store.data.bkImageRect.y = this.store.data.bkImageRect.y ? Number(this.store.data.bkImageRect.y) : 0;
|
212
|
+
this.store.data.bkImageRect.width = this.store.data.bkImageRect.width ? Number(this.store.data.bkImageRect.width) : this.canvas.width;
|
213
|
+
this.store.data.bkImageRect.height = this.store.data.bkImageRect.height ? Number(this.store.data.bkImageRect.height) : this.canvas.height;
|
214
|
+
this.store.data.bkImageRect.center = {
|
215
|
+
x: this.store.data.bkImageRect.x + this.store.data.bkImageRect.width / 2,
|
216
|
+
y: this.store.data.bkImageRect.y + this.store.data.bkImageRect.height / 2
|
217
|
+
}
|
193
218
|
}
|
194
|
-
}
|
195
219
|
};
|
196
220
|
Preview.prototype.scale = function (scale, center, w, h) {
|
197
221
|
if (this.store.data.scale * scale < this.store.options.minScale ||
|
198
222
|
this.store.data.scale * scale > this.store.options.maxScale) {
|
199
223
|
return;
|
200
224
|
}
|
201
|
-
const scaleX = w ? w : scale;
|
202
|
-
const scaleY = h ? h : scale;
|
203
225
|
this.store.data.scale *= scale;
|
204
|
-
if(this.isFullScreen) {
|
205
|
-
this.store.ratioCord.ratio *= scale;
|
206
|
-
this.store.ratioCord.scaleX *= scaleX;
|
207
|
-
this.store.ratioCord.scaleY *= scaleY;
|
208
|
-
}else {
|
209
|
-
this.store.ratioCord = {
|
210
|
-
ratio: 1,
|
211
|
-
scaleX: 1,
|
212
|
-
scaleY: 1
|
213
|
-
}
|
214
|
-
}
|
215
226
|
!center && (center = this.getRect().center);
|
216
227
|
for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
|
217
228
|
var item = _a[_i];
|
@@ -228,7 +239,12 @@ var Preview = (function (_super) {
|
|
228
239
|
return;
|
229
240
|
// 1. 重置画布尺寸为容器尺寸
|
230
241
|
var parentElem = this.store.parentElem;
|
231
|
-
var width = parentElem.offsetWidth,
|
242
|
+
var width = parentElem.offsetWidth,
|
243
|
+
height = parentElem.offsetHeight;
|
244
|
+
if(this.store.options.storeSubscribe) {
|
245
|
+
width = this.store.options.width;
|
246
|
+
height = this.store.options.height;
|
247
|
+
}
|
232
248
|
this.canvasResize({
|
233
249
|
width: width,
|
234
250
|
height: height,
|
@@ -239,6 +255,11 @@ var Preview = (function (_super) {
|
|
239
255
|
var padding = formatPadding(viewPadding || this.store.options.viewPadding);
|
240
256
|
// 4. 获取图形尺寸
|
241
257
|
var rect = this.getRect();
|
258
|
+
if(!rect.width) {
|
259
|
+
const bkImageRect = this.store.data.bkImageRect;
|
260
|
+
rect.width = bkImageRect && bkImageRect.width ? bkImageRect.width : width;
|
261
|
+
rect.height = bkImageRect && bkImageRect.height ? bkImageRect.height : height;
|
262
|
+
}
|
242
263
|
// 6. 计算缩放比
|
243
264
|
var w = (width - padding[1] - padding[3]) / rect.width;
|
244
265
|
var h = (height - padding[0] - padding[2]) / rect.height;
|
@@ -246,11 +267,8 @@ var Preview = (function (_super) {
|
|
246
267
|
if (w > h) {
|
247
268
|
ratio = h;
|
248
269
|
}
|
249
|
-
|
250
|
-
|
251
|
-
w = 1 / this.store.ratioCord.scaleX;
|
252
|
-
h = 1 / this.store.ratioCord.scaleY;
|
253
|
-
}
|
270
|
+
// 保持缩放后的还原度
|
271
|
+
if(typeof restore === 'boolean' && restore) ratio = w;
|
254
272
|
this.scale(ratio, undefined, w, h);
|
255
273
|
this.canvas.scale(ratio, undefined, w, h);
|
256
274
|
// 7. X抽滚动条隐藏
|
@@ -261,6 +279,7 @@ var Preview = (function (_super) {
|
|
261
279
|
this.onMouseMove = null;
|
262
280
|
this.onmousedown = null;
|
263
281
|
this.onmouseup = null;
|
282
|
+
window.onresize = null;
|
264
283
|
};
|
265
284
|
return Preview;
|
266
285
|
}(Common));
|
@@ -5,12 +5,6 @@ export declare class RenderLayer extends Canvas {
|
|
5
5
|
offscreen: any;
|
6
6
|
bkImg: HTMLImageElement;
|
7
7
|
bkImgRect: {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
width: number;
|
11
|
-
height: number;
|
12
|
-
};
|
13
|
-
bgRect: {
|
14
8
|
center: {
|
15
9
|
x: number;
|
16
10
|
y: number;
|
@@ -20,6 +14,16 @@ export declare class RenderLayer extends Canvas {
|
|
20
14
|
width: number;
|
21
15
|
height: number;
|
22
16
|
};
|
17
|
+
bgRect: {
|
18
|
+
// center: {
|
19
|
+
// x: number;
|
20
|
+
// y: number;
|
21
|
+
// },
|
22
|
+
x: number;
|
23
|
+
y: number;
|
24
|
+
// width: number;
|
25
|
+
// height: number;
|
26
|
+
};
|
23
27
|
constructor(TID: String);
|
24
28
|
loadBkImg(cb?: any): void;
|
25
29
|
clearBkImg(): void;
|
package/core/src/renderLayer.js
CHANGED
@@ -24,6 +24,9 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
24
24
|
_this.initImage = false;
|
25
25
|
_this.coverType = 'container';
|
26
26
|
_this.bgRect = null;
|
27
|
+
_this.scaleX = 1;
|
28
|
+
_this.scaleY = 1;
|
29
|
+
_this.ratio = 1;
|
27
30
|
_this.render = function () {
|
28
31
|
if(!commonStore || !commonStore[TID]) return;
|
29
32
|
if (commonStore[TID].data.bkImage && !_this.initImage) {
|
@@ -50,41 +53,34 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
50
53
|
return _this;
|
51
54
|
}
|
52
55
|
RenderLayer.prototype.scale = function (scale, center, w, h){
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
if(!this.bkImgRect) {
|
57
|
+
this.scaleX = w ? w : scale;
|
58
|
+
this.scaleY = h ? h : scale;
|
59
|
+
this.ratio = scale;
|
60
|
+
return;
|
61
|
+
}
|
58
62
|
if(!center) {
|
59
|
-
center =
|
63
|
+
center = this.bkImgRect.center;
|
60
64
|
}
|
61
65
|
if (!w) {
|
62
66
|
w = scale;
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
this.bgRect.x = center.x - (center.x - this.bgRect.x) * w;
|
67
|
-
}
|
67
|
+
this.bkImgRect.x = center.x - (center.x - this.bkImgRect.x) * scale;
|
68
|
+
}else {
|
69
|
+
this.bkImgRect.x = this.bgRect.x;
|
68
70
|
}
|
69
71
|
if (!h) {
|
70
72
|
h = scale;
|
71
|
-
|
72
|
-
bkImageRect.y = center.y - (center.y - bkImageRect.y) * h;
|
73
|
-
}else {
|
74
|
-
this.bgRect.y = center.y - (center.y - this.bgRect.y) * h;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
if(bkImageRect) {
|
78
|
-
bkImageRect.width *= w;
|
79
|
-
bkImageRect.height *= h;
|
80
|
-
this.bkImgRect = bkImageRect;
|
73
|
+
this.bkImgRect.y = center.y - (center.y - this.bkImgRect.y) * scale;
|
81
74
|
}else {
|
82
|
-
|
83
|
-
this.bgRect.width *= w;
|
84
|
-
this.bgRect.height *= h;
|
85
|
-
}
|
86
|
-
this.bkImgRect = this.bgRect;
|
75
|
+
this.bkImgRect.y = this.bgRect.y;
|
87
76
|
}
|
77
|
+
this.bkImgRect.width *= w;
|
78
|
+
this.bkImgRect.height *= h;
|
79
|
+
this.calcCenter();
|
80
|
+
};
|
81
|
+
RenderLayer.prototype.calcCenter = function () {
|
82
|
+
this.bkImgRect.center.x = this.bkImgRect.x + this.bkImgRect.width / 2;
|
83
|
+
this.bkImgRect.center.y = this.bkImgRect.y + this.bkImgRect.height / 2;
|
88
84
|
};
|
89
85
|
RenderLayer.prototype.loadBkImg = function (cb, pixi) {
|
90
86
|
var _this = this;
|
@@ -98,6 +94,7 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
98
94
|
this.bkImg.onload = function () {
|
99
95
|
if(pixi && !_this.bkImgRect) {
|
100
96
|
_this.bkImgRectResize({width: _this.canvas.width, height: _this.canvas.height});
|
97
|
+
_this.scale(_this.ratio, undefined, _this.scaleX, _this.scaleY);
|
101
98
|
}else {
|
102
99
|
//_this.bkImgRect = _this.coverRect(_this.canvas.width, _this.canvas.height, _this.bkImg.width, _this.bkImg.height);
|
103
100
|
}
|
@@ -105,10 +102,6 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
105
102
|
cb();
|
106
103
|
}
|
107
104
|
_this.initImage = true;
|
108
|
-
_this.bgRect.center.x = _this.width / 2;
|
109
|
-
_this.bgRect.center.y = _this.height / 2;
|
110
|
-
_this.bgRect.width = _this.width;
|
111
|
-
_this.bgRect.height = _this.height;
|
112
105
|
};
|
113
106
|
};
|
114
107
|
RenderLayer.prototype.clearBkImg = function () {
|
@@ -116,14 +109,8 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
116
109
|
this.bkImg = null;
|
117
110
|
this.initImage = false;
|
118
111
|
this.bgRect = {
|
119
|
-
center: {
|
120
|
-
x: this.width / 2,
|
121
|
-
y: this.height / 2
|
122
|
-
},
|
123
112
|
x: 0,
|
124
|
-
y: 0
|
125
|
-
width: this.width,
|
126
|
-
height: this.height
|
113
|
+
y: 0
|
127
114
|
}
|
128
115
|
};
|
129
116
|
RenderLayer.prototype.coverRect = function (canvasWidth, canvasHeight, imgWidth, imgHeight) {
|
@@ -157,13 +144,19 @@ var RenderLayer = /** @class */ (function (_super) {
|
|
157
144
|
let bkWidth = bkImageRect.width ? Number(bkImageRect.width) : width;
|
158
145
|
let bkHeight = bkImageRect.height ? Number(bkImageRect.height) : height;
|
159
146
|
this.bkImgRect = {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
147
|
+
center: {
|
148
|
+
x: x + bkWidth / 2,
|
149
|
+
y: y + bkHeight / 2
|
150
|
+
},
|
151
|
+
x,
|
152
|
+
y,
|
153
|
+
width: bkWidth,
|
154
|
+
height: bkHeight
|
155
|
+
};
|
156
|
+
this.bgRect = {
|
157
|
+
x,
|
158
|
+
y
|
164
159
|
};
|
165
|
-
}else {
|
166
|
-
this.bkImgRect = this.bgRect;
|
167
160
|
}
|
168
161
|
};
|
169
162
|
|