@leafer/core 1.0.0-rc.3 → 1.0.0-rc.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/dist/core.cjs +152 -142
- package/dist/core.esm.js +153 -142
- package/dist/core.esm.min.js +1 -1
- package/dist/core.min.cjs +1 -1
- package/package.json +21 -21
package/dist/core.cjs
CHANGED
|
@@ -656,7 +656,7 @@ const BoundsHelper = {
|
|
|
656
656
|
B.copyAndSpread(n, t, spreadX, spreadY);
|
|
657
657
|
return n;
|
|
658
658
|
},
|
|
659
|
-
spread(t, spreadX, spreadY) {
|
|
659
|
+
spread(t, spreadX, spreadY = spreadX) {
|
|
660
660
|
B.copyAndSpread(t, t, spreadX, spreadY);
|
|
661
661
|
},
|
|
662
662
|
ceil(t) {
|
|
@@ -797,8 +797,8 @@ class Bounds {
|
|
|
797
797
|
getFitMatrix(put) {
|
|
798
798
|
return BoundsHelper.getFitMatrix(this, put);
|
|
799
799
|
}
|
|
800
|
-
spread(
|
|
801
|
-
BoundsHelper.spread(this,
|
|
800
|
+
spread(spreadX, spreadY) {
|
|
801
|
+
BoundsHelper.spread(this, spreadX, spreadY);
|
|
802
802
|
return this;
|
|
803
803
|
}
|
|
804
804
|
ceil() {
|
|
@@ -1380,6 +1380,8 @@ class LeafData {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
|
|
1382
1382
|
const FileHelper = {
|
|
1383
|
+
opacityTypes: ['png', 'webp', 'svg'],
|
|
1384
|
+
upperCaseTypeMap: {},
|
|
1383
1385
|
mineType(type) {
|
|
1384
1386
|
if (!type || type.startsWith('image'))
|
|
1385
1387
|
return type;
|
|
@@ -1392,6 +1394,7 @@ const FileHelper = {
|
|
|
1392
1394
|
return l[l.length - 1];
|
|
1393
1395
|
}
|
|
1394
1396
|
};
|
|
1397
|
+
FileHelper.opacityTypes.forEach(type => FileHelper.upperCaseTypeMap[type] = type.toUpperCase());
|
|
1395
1398
|
|
|
1396
1399
|
/******************************************************************************
|
|
1397
1400
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2332,7 +2335,7 @@ const EllipseHelper = {
|
|
|
2332
2335
|
const centerX = fromX + halfX + rotationCos * cx - rotationSin * cy;
|
|
2333
2336
|
const centerY = fromY + halfY + rotationSin * cx + rotationCos * cy;
|
|
2334
2337
|
const anticlockwise = totalRadian < 0 ? 1 : 0;
|
|
2335
|
-
if (curveMode) {
|
|
2338
|
+
if (curveMode || Platform.name === 'node') {
|
|
2336
2339
|
ellipse$4(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise);
|
|
2337
2340
|
}
|
|
2338
2341
|
else {
|
|
@@ -3259,6 +3262,23 @@ const ImageManager = {
|
|
|
3259
3262
|
list.length = 0;
|
|
3260
3263
|
}
|
|
3261
3264
|
},
|
|
3265
|
+
isPixel(config) {
|
|
3266
|
+
return FileHelper.opacityTypes.some(item => I$1.isFormat(item, config));
|
|
3267
|
+
},
|
|
3268
|
+
isFormat(format, config) {
|
|
3269
|
+
if (config.format === format)
|
|
3270
|
+
return true;
|
|
3271
|
+
const { url } = config;
|
|
3272
|
+
if (url.startsWith('data:')) {
|
|
3273
|
+
if (url.startsWith('data:' + FileHelper.mineType(format)))
|
|
3274
|
+
return true;
|
|
3275
|
+
}
|
|
3276
|
+
else {
|
|
3277
|
+
if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
|
|
3278
|
+
return true;
|
|
3279
|
+
}
|
|
3280
|
+
return false;
|
|
3281
|
+
},
|
|
3262
3282
|
destroy() {
|
|
3263
3283
|
I$1.map = {};
|
|
3264
3284
|
}
|
|
@@ -3274,17 +3294,7 @@ class LeaferImage {
|
|
|
3274
3294
|
this.waitComplete = [];
|
|
3275
3295
|
this.innerId = create$1(IMAGE);
|
|
3276
3296
|
this.config = config || { url: '' };
|
|
3277
|
-
|
|
3278
|
-
if (url.startsWith('data:')) {
|
|
3279
|
-
if (url.startsWith('data:image/svg'))
|
|
3280
|
-
this.isSVG = true;
|
|
3281
|
-
}
|
|
3282
|
-
else {
|
|
3283
|
-
if (url.includes('.svg'))
|
|
3284
|
-
this.isSVG = true;
|
|
3285
|
-
}
|
|
3286
|
-
if (this.config.format === 'svg')
|
|
3287
|
-
this.isSVG = true;
|
|
3297
|
+
this.isSVG = ImageManager.isFormat('svg', config);
|
|
3288
3298
|
}
|
|
3289
3299
|
load(onSuccess, onError) {
|
|
3290
3300
|
if (!this.loading) {
|
|
@@ -3357,13 +3367,19 @@ class Event {
|
|
|
3357
3367
|
}
|
|
3358
3368
|
stopDefault() {
|
|
3359
3369
|
this.isStopDefault = true;
|
|
3370
|
+
if (this.origin)
|
|
3371
|
+
Platform.event.stopDefault(this.origin);
|
|
3360
3372
|
}
|
|
3361
3373
|
stopNow() {
|
|
3362
3374
|
this.isStopNow = true;
|
|
3363
3375
|
this.isStop = true;
|
|
3376
|
+
if (this.origin)
|
|
3377
|
+
Platform.event.stopNow(this.origin);
|
|
3364
3378
|
}
|
|
3365
3379
|
stop() {
|
|
3366
3380
|
this.isStop = true;
|
|
3381
|
+
if (this.origin)
|
|
3382
|
+
Platform.event.stop(this.origin);
|
|
3367
3383
|
}
|
|
3368
3384
|
}
|
|
3369
3385
|
|
|
@@ -3425,20 +3441,6 @@ class ResizeEvent extends Event {
|
|
|
3425
3441
|
}
|
|
3426
3442
|
ResizeEvent.RESIZE = 'resize';
|
|
3427
3443
|
|
|
3428
|
-
class TransformEvent extends Event {
|
|
3429
|
-
constructor(type, params) {
|
|
3430
|
-
super(type);
|
|
3431
|
-
if (params)
|
|
3432
|
-
Object.assign(this, params);
|
|
3433
|
-
}
|
|
3434
|
-
}
|
|
3435
|
-
TransformEvent.START = 'transform.start';
|
|
3436
|
-
TransformEvent.CHANGE = 'transform.change';
|
|
3437
|
-
TransformEvent.END = 'transform.end';
|
|
3438
|
-
TransformEvent.BEFORE_START = 'transform.before_start';
|
|
3439
|
-
TransformEvent.BEFORE_CHANGE = 'transform.before_change';
|
|
3440
|
-
TransformEvent.BEFORE_END = 'transform.before_end';
|
|
3441
|
-
|
|
3442
3444
|
class WatchEvent extends Event {
|
|
3443
3445
|
constructor(type, data) {
|
|
3444
3446
|
super(type);
|
|
@@ -3539,15 +3541,15 @@ class UIEvent extends Event {
|
|
|
3539
3541
|
this.bubbles = true;
|
|
3540
3542
|
Object.assign(this, params);
|
|
3541
3543
|
}
|
|
3542
|
-
getInner(
|
|
3543
|
-
if (!
|
|
3544
|
-
|
|
3545
|
-
return
|
|
3544
|
+
getInner(relative) {
|
|
3545
|
+
if (!relative)
|
|
3546
|
+
relative = this.current;
|
|
3547
|
+
return relative.getInnerPoint(this);
|
|
3546
3548
|
}
|
|
3547
|
-
getLocal(
|
|
3548
|
-
if (!
|
|
3549
|
-
|
|
3550
|
-
return
|
|
3549
|
+
getLocal(relative) {
|
|
3550
|
+
if (!relative)
|
|
3551
|
+
relative = this.current;
|
|
3552
|
+
return relative.getLocalPoint(this);
|
|
3551
3553
|
}
|
|
3552
3554
|
static changeName(oldName, newName) {
|
|
3553
3555
|
EventCreator.changeName(oldName, newName);
|
|
@@ -3594,7 +3596,7 @@ function positionType(defaultValue) {
|
|
|
3594
3596
|
defineLeafAttr(target, key, defaultValue, {
|
|
3595
3597
|
set(value) {
|
|
3596
3598
|
this.__setAttr(key, value);
|
|
3597
|
-
this.__layout.
|
|
3599
|
+
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3598
3600
|
}
|
|
3599
3601
|
});
|
|
3600
3602
|
};
|
|
@@ -3626,7 +3628,7 @@ function boundsType(defaultValue) {
|
|
|
3626
3628
|
this.__setAttr(key, value);
|
|
3627
3629
|
this.__layout.boxChanged || this.__layout.boxChange();
|
|
3628
3630
|
if (this.__.around)
|
|
3629
|
-
this.__layout.
|
|
3631
|
+
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3630
3632
|
}
|
|
3631
3633
|
});
|
|
3632
3634
|
};
|
|
@@ -3862,29 +3864,36 @@ exports.PointerEvent.CLICK = 'click';
|
|
|
3862
3864
|
exports.PointerEvent.DOUBLE_CLICK = 'double_click';
|
|
3863
3865
|
exports.PointerEvent.LONG_PRESS = 'long_press';
|
|
3864
3866
|
exports.PointerEvent.LONG_TAP = 'long_tap';
|
|
3867
|
+
exports.PointerEvent.MENU = 'pointer.menu';
|
|
3865
3868
|
exports.PointerEvent = __decorate([
|
|
3866
3869
|
registerUIEvent()
|
|
3867
3870
|
], exports.PointerEvent);
|
|
3868
3871
|
|
|
3869
3872
|
const move = {};
|
|
3870
3873
|
exports.DragEvent = class DragEvent extends exports.PointerEvent {
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
+
static setList(data) {
|
|
3875
|
+
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
3876
|
+
}
|
|
3877
|
+
static setData(data) {
|
|
3878
|
+
this.data = data;
|
|
3879
|
+
}
|
|
3880
|
+
getInnerMove(relative, total) {
|
|
3881
|
+
if (!relative)
|
|
3882
|
+
relative = this.current;
|
|
3874
3883
|
this.assignMove(total);
|
|
3875
|
-
return
|
|
3884
|
+
return relative.getInnerPoint(move, null, true);
|
|
3876
3885
|
}
|
|
3877
|
-
getLocalMove(
|
|
3878
|
-
if (!
|
|
3879
|
-
|
|
3886
|
+
getLocalMove(relative, total) {
|
|
3887
|
+
if (!relative)
|
|
3888
|
+
relative = this.current;
|
|
3880
3889
|
this.assignMove(total);
|
|
3881
|
-
return
|
|
3890
|
+
return relative.getLocalPoint(move, null, true);
|
|
3882
3891
|
}
|
|
3883
|
-
getInnerTotal(
|
|
3884
|
-
return this.getInnerMove(
|
|
3892
|
+
getInnerTotal(relative) {
|
|
3893
|
+
return this.getInnerMove(relative, true);
|
|
3885
3894
|
}
|
|
3886
|
-
getLocalTotal(
|
|
3887
|
-
return this.getLocalMove(
|
|
3895
|
+
getLocalTotal(relative) {
|
|
3896
|
+
return this.getLocalMove(relative, true);
|
|
3888
3897
|
}
|
|
3889
3898
|
assignMove(total) {
|
|
3890
3899
|
move.x = total ? this.totalX : this.moveX;
|
|
@@ -3903,17 +3912,16 @@ exports.DragEvent = __decorate([
|
|
|
3903
3912
|
registerUIEvent()
|
|
3904
3913
|
], exports.DragEvent);
|
|
3905
3914
|
|
|
3906
|
-
|
|
3907
|
-
exports.DropEvent = DropEvent_1 = class DropEvent extends exports.PointerEvent {
|
|
3915
|
+
exports.DropEvent = class DropEvent extends exports.PointerEvent {
|
|
3908
3916
|
static setList(data) {
|
|
3909
|
-
|
|
3917
|
+
exports.DragEvent.setList(data);
|
|
3910
3918
|
}
|
|
3911
3919
|
static setData(data) {
|
|
3912
|
-
|
|
3920
|
+
exports.DragEvent.setData(data);
|
|
3913
3921
|
}
|
|
3914
3922
|
};
|
|
3915
3923
|
exports.DropEvent.DROP = 'drop';
|
|
3916
|
-
exports.DropEvent =
|
|
3924
|
+
exports.DropEvent = __decorate([
|
|
3917
3925
|
registerUIEvent()
|
|
3918
3926
|
], exports.DropEvent);
|
|
3919
3927
|
|
|
@@ -4020,7 +4028,6 @@ class Transformer {
|
|
|
4020
4028
|
this.moveEnd();
|
|
4021
4029
|
this.zoomEnd();
|
|
4022
4030
|
this.rotateEnd();
|
|
4023
|
-
this.transformMode = null;
|
|
4024
4031
|
}
|
|
4025
4032
|
moveEnd() {
|
|
4026
4033
|
if (this.moveData) {
|
|
@@ -4045,7 +4052,7 @@ class Transformer {
|
|
|
4045
4052
|
}
|
|
4046
4053
|
}
|
|
4047
4054
|
|
|
4048
|
-
const { copy: copy$2,
|
|
4055
|
+
const { copy: copy$2, toInnerPoint: toInnerPoint$1, scaleOfOuter, rotateOfOuter, skewOfOuter } = MatrixHelper;
|
|
4049
4056
|
const matrix = {};
|
|
4050
4057
|
const LeafHelper = {
|
|
4051
4058
|
updateAllWorldMatrix(leaf) {
|
|
@@ -4088,63 +4095,41 @@ const LeafHelper = {
|
|
|
4088
4095
|
return true;
|
|
4089
4096
|
},
|
|
4090
4097
|
moveWorld(t, x, y) {
|
|
4091
|
-
t.__layout.checkUpdate();
|
|
4092
4098
|
const local = { x, y };
|
|
4093
4099
|
if (t.parent)
|
|
4094
|
-
toInnerPoint$1(t.parent.
|
|
4100
|
+
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4095
4101
|
L.moveLocal(t, local.x, local.y);
|
|
4096
4102
|
},
|
|
4097
4103
|
moveLocal(t, x, y = 0) {
|
|
4098
4104
|
t.x += x;
|
|
4099
4105
|
t.y += y;
|
|
4100
4106
|
},
|
|
4101
|
-
zoomOfWorld(t, origin, scaleX, scaleY
|
|
4102
|
-
|
|
4103
|
-
const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
|
|
4104
|
-
this.zoomOfLocal(t, local, scaleX, scaleY, moveLayer);
|
|
4107
|
+
zoomOfWorld(t, origin, scaleX, scaleY) {
|
|
4108
|
+
this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
|
|
4105
4109
|
},
|
|
4106
|
-
zoomOfLocal(t, origin, scaleX, scaleY = scaleX
|
|
4110
|
+
zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
|
|
4107
4111
|
copy$2(matrix, t.__local);
|
|
4108
|
-
if (moveLayer)
|
|
4109
|
-
translate(matrix, moveLayer.x, moveLayer.y);
|
|
4110
4112
|
scaleOfOuter(matrix, origin, scaleX, scaleY);
|
|
4111
|
-
|
|
4112
|
-
moveLayer = t;
|
|
4113
|
-
moveLayer.x += matrix.e - t.__local.e;
|
|
4114
|
-
moveLayer.y += matrix.f - t.__local.f;
|
|
4113
|
+
moveByMatrix(t, matrix);
|
|
4115
4114
|
t.scaleX *= scaleX;
|
|
4116
4115
|
t.scaleY *= scaleY;
|
|
4117
4116
|
},
|
|
4118
|
-
rotateOfWorld(t, origin, angle
|
|
4119
|
-
|
|
4120
|
-
const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
|
|
4121
|
-
this.rotateOfLocal(t, local, angle, moveLayer);
|
|
4117
|
+
rotateOfWorld(t, origin, angle) {
|
|
4118
|
+
this.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
4122
4119
|
},
|
|
4123
|
-
rotateOfLocal(t, origin, angle
|
|
4120
|
+
rotateOfLocal(t, origin, angle) {
|
|
4124
4121
|
copy$2(matrix, t.__local);
|
|
4125
|
-
if (moveLayer)
|
|
4126
|
-
translate(matrix, moveLayer.x, moveLayer.y);
|
|
4127
4122
|
rotateOfOuter(matrix, origin, angle);
|
|
4128
|
-
|
|
4129
|
-
moveLayer = t;
|
|
4130
|
-
moveLayer.x += matrix.e - t.__local.e;
|
|
4131
|
-
moveLayer.y += matrix.f - t.__local.f;
|
|
4123
|
+
moveByMatrix(t, matrix);
|
|
4132
4124
|
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4133
4125
|
},
|
|
4134
|
-
skewOfWorld(t, origin, skewX, skewY
|
|
4135
|
-
|
|
4136
|
-
const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
|
|
4137
|
-
this.skewOfLocal(t, local, skewX, skewY, moveLayer);
|
|
4126
|
+
skewOfWorld(t, origin, skewX, skewY) {
|
|
4127
|
+
this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
|
|
4138
4128
|
},
|
|
4139
|
-
skewOfLocal(t, origin, skewX, skewY
|
|
4129
|
+
skewOfLocal(t, origin, skewX, skewY) {
|
|
4140
4130
|
copy$2(matrix, t.__local);
|
|
4141
|
-
if (moveLayer)
|
|
4142
|
-
translate(matrix, moveLayer.x, moveLayer.y);
|
|
4143
4131
|
skewOfOuter(matrix, origin, skewX, skewY);
|
|
4144
|
-
|
|
4145
|
-
moveLayer = t;
|
|
4146
|
-
moveLayer.x = matrix.e - t.__local.e;
|
|
4147
|
-
moveLayer.y = matrix.f - t.__local.f;
|
|
4132
|
+
moveByMatrix(t, matrix);
|
|
4148
4133
|
t.skewX = MathHelper.formatSkew(t.skewX + skewX);
|
|
4149
4134
|
t.skewY = MathHelper.formatSkew(t.skewY + skewY);
|
|
4150
4135
|
},
|
|
@@ -4158,6 +4143,14 @@ const LeafHelper = {
|
|
|
4158
4143
|
};
|
|
4159
4144
|
const L = LeafHelper;
|
|
4160
4145
|
const { updateAllWorldMatrix, updateAllWorldOpacity, updateAllChange } = L;
|
|
4146
|
+
function moveByMatrix(t, matrix) {
|
|
4147
|
+
t.x += matrix.e - t.__local.e;
|
|
4148
|
+
t.y += matrix.f - t.__local.f;
|
|
4149
|
+
}
|
|
4150
|
+
function getTempLocal(t, world) {
|
|
4151
|
+
t.__layout.checkUpdate();
|
|
4152
|
+
return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
|
|
4153
|
+
}
|
|
4161
4154
|
|
|
4162
4155
|
const LeafBoundsHelper = {
|
|
4163
4156
|
worldBounds(target) {
|
|
@@ -4319,7 +4312,8 @@ const InteractionHelper = {
|
|
|
4319
4312
|
};
|
|
4320
4313
|
const I = InteractionHelper;
|
|
4321
4314
|
|
|
4322
|
-
const
|
|
4315
|
+
const emptyList = new LeafList();
|
|
4316
|
+
const { getDragEventData, getDropEventData, getSwipeEventData } = InteractionHelper;
|
|
4323
4317
|
class Dragger {
|
|
4324
4318
|
constructor(interaction) {
|
|
4325
4319
|
this.interaction = interaction;
|
|
@@ -4327,8 +4321,8 @@ class Dragger {
|
|
|
4327
4321
|
setDragData(data) {
|
|
4328
4322
|
this.dragData = getDragEventData(data, data, data);
|
|
4329
4323
|
}
|
|
4330
|
-
|
|
4331
|
-
return this.dragging ? exports.
|
|
4324
|
+
getList() {
|
|
4325
|
+
return this.dragging ? (exports.DragEvent.list || this.interaction.selector.list || this.dragableList || emptyList) : emptyList;
|
|
4332
4326
|
}
|
|
4333
4327
|
checkDrag(data, canDrag) {
|
|
4334
4328
|
const { interaction } = this;
|
|
@@ -4357,7 +4351,7 @@ class Dragger {
|
|
|
4357
4351
|
interaction.emit(exports.MoveEvent.MOVE, this.dragData);
|
|
4358
4352
|
}
|
|
4359
4353
|
else if (this.dragging) {
|
|
4360
|
-
this.
|
|
4354
|
+
this.realDrag();
|
|
4361
4355
|
interaction.emit(exports.DragEvent.BEFORE_DRAG, this.dragData);
|
|
4362
4356
|
interaction.emit(exports.DragEvent.DRAG, this.dragData);
|
|
4363
4357
|
}
|
|
@@ -4368,9 +4362,6 @@ class Dragger {
|
|
|
4368
4362
|
if (this.dragging) {
|
|
4369
4363
|
this.interaction.emit(exports.DragEvent.START, this.dragData);
|
|
4370
4364
|
this.getDragableList(this.dragData.path);
|
|
4371
|
-
this.dragList = filterPathByEventType(this.dragData.path, exports.DragEvent.DRAG);
|
|
4372
|
-
if (!this.dragList.length && this.dragableList)
|
|
4373
|
-
this.dragList.pushList(this.dragableList);
|
|
4374
4365
|
}
|
|
4375
4366
|
}
|
|
4376
4367
|
}
|
|
@@ -4379,16 +4370,17 @@ class Dragger {
|
|
|
4379
4370
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
4380
4371
|
leaf = path.list[i];
|
|
4381
4372
|
if (leaf.__.draggable && leaf.__.hitSelf) {
|
|
4382
|
-
this.dragableList =
|
|
4373
|
+
this.dragableList = new LeafList(leaf);
|
|
4383
4374
|
break;
|
|
4384
4375
|
}
|
|
4385
4376
|
}
|
|
4386
4377
|
}
|
|
4387
|
-
|
|
4378
|
+
realDrag() {
|
|
4388
4379
|
const { running } = this.interaction;
|
|
4389
|
-
|
|
4380
|
+
const list = this.getList();
|
|
4381
|
+
if (list.length && running) {
|
|
4390
4382
|
const { moveX, moveY } = this.dragData;
|
|
4391
|
-
|
|
4383
|
+
list.forEach(leaf => {
|
|
4392
4384
|
LeafHelper.moveWorld(leaf, moveX, moveY);
|
|
4393
4385
|
});
|
|
4394
4386
|
}
|
|
@@ -4445,20 +4437,14 @@ class Dragger {
|
|
|
4445
4437
|
}
|
|
4446
4438
|
}
|
|
4447
4439
|
drop(data) {
|
|
4448
|
-
const dropData = getDropEventData(data, this.
|
|
4440
|
+
const dropData = getDropEventData(data, this.getList(), exports.DragEvent.data);
|
|
4449
4441
|
dropData.path = this.dragEnterPath;
|
|
4450
4442
|
this.interaction.emit(exports.DropEvent.DROP, dropData);
|
|
4451
4443
|
this.interaction.emit(exports.DragEvent.LEAVE, data, this.dragEnterPath);
|
|
4452
4444
|
}
|
|
4453
4445
|
dragReset() {
|
|
4454
|
-
exports.
|
|
4455
|
-
this.
|
|
4456
|
-
this.dragableList = null;
|
|
4457
|
-
this.dragData = null;
|
|
4458
|
-
this.dragOverPath = null;
|
|
4459
|
-
this.dragEnterPath = null;
|
|
4460
|
-
this.dragging = null;
|
|
4461
|
-
this.moving = null;
|
|
4446
|
+
exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.dragOverPath = this.dragEnterPath = null;
|
|
4447
|
+
this.dragging = this.moving = false;
|
|
4462
4448
|
}
|
|
4463
4449
|
checkDragOut(data) {
|
|
4464
4450
|
const { interaction } = this;
|
|
@@ -4593,7 +4579,8 @@ class InteractionBase {
|
|
|
4593
4579
|
dragDistance: 2,
|
|
4594
4580
|
swipeDistance: 20,
|
|
4595
4581
|
ignoreMove: false
|
|
4596
|
-
}
|
|
4582
|
+
},
|
|
4583
|
+
cursor: {}
|
|
4597
4584
|
};
|
|
4598
4585
|
this.tapCount = 0;
|
|
4599
4586
|
this.downKeyMap = {};
|
|
@@ -4693,6 +4680,10 @@ class InteractionBase {
|
|
|
4693
4680
|
this.zoom(getZoomEventData(center, scale, data));
|
|
4694
4681
|
this.move(getMoveEventData(center, move, data));
|
|
4695
4682
|
}
|
|
4683
|
+
menu(data) {
|
|
4684
|
+
this.findPath(data);
|
|
4685
|
+
this.emit(exports.PointerEvent.MENU, data);
|
|
4686
|
+
}
|
|
4696
4687
|
move(data) {
|
|
4697
4688
|
this.transformer.move(data);
|
|
4698
4689
|
}
|
|
@@ -4802,6 +4793,9 @@ class InteractionBase {
|
|
|
4802
4793
|
data.path = find.path;
|
|
4803
4794
|
return find.path;
|
|
4804
4795
|
}
|
|
4796
|
+
isDrag(leaf) {
|
|
4797
|
+
return this.dragger.getList().has(leaf);
|
|
4798
|
+
}
|
|
4805
4799
|
updateDownData(data) {
|
|
4806
4800
|
if (!data)
|
|
4807
4801
|
data = this.downData;
|
|
@@ -4815,10 +4809,12 @@ class InteractionBase {
|
|
|
4815
4809
|
data = this.hoverData;
|
|
4816
4810
|
if (!data)
|
|
4817
4811
|
return;
|
|
4818
|
-
this.findPath(data, { exclude: this.dragger.
|
|
4812
|
+
this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
|
|
4819
4813
|
this.hoverData = data;
|
|
4820
4814
|
}
|
|
4821
4815
|
updateCursor(data) {
|
|
4816
|
+
if (this.config.cursor.stop)
|
|
4817
|
+
return;
|
|
4822
4818
|
if (!data) {
|
|
4823
4819
|
this.updateHoverData();
|
|
4824
4820
|
data = this.hoverData;
|
|
@@ -4831,17 +4827,16 @@ class InteractionBase {
|
|
|
4831
4827
|
}
|
|
4832
4828
|
else if (!data || this.dragger.dragging)
|
|
4833
4829
|
return;
|
|
4834
|
-
const path = data.path;
|
|
4835
4830
|
let leaf;
|
|
4831
|
+
let cursor;
|
|
4832
|
+
const { path } = data;
|
|
4836
4833
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
4837
4834
|
leaf = path.list[i];
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
return;
|
|
4842
|
-
}
|
|
4835
|
+
cursor = leaf.cursor;
|
|
4836
|
+
if (cursor)
|
|
4837
|
+
break;
|
|
4843
4838
|
}
|
|
4844
|
-
this.setCursor(
|
|
4839
|
+
this.setCursor(cursor);
|
|
4845
4840
|
}
|
|
4846
4841
|
setCursor(cursor) {
|
|
4847
4842
|
this.cursor = cursor;
|
|
@@ -4934,7 +4929,7 @@ class LeafLayout {
|
|
|
4934
4929
|
this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4935
4930
|
this.localRenderBounds = this.localStrokeBounds = leaf.__local;
|
|
4936
4931
|
this.boxChange();
|
|
4937
|
-
this.
|
|
4932
|
+
this.matrixChange();
|
|
4938
4933
|
}
|
|
4939
4934
|
checkUpdate(force) {
|
|
4940
4935
|
const { leafer } = this.leaf;
|
|
@@ -5061,11 +5056,6 @@ class LeafLayout {
|
|
|
5061
5056
|
this.renderSpread || (this.renderSpread = 1);
|
|
5062
5057
|
this.boundsChanged = true;
|
|
5063
5058
|
}
|
|
5064
|
-
positionChange() {
|
|
5065
|
-
this.positionChanged = true;
|
|
5066
|
-
this.matrixChanged = true;
|
|
5067
|
-
this.localBoxChanged || this.localBoxChange();
|
|
5068
|
-
}
|
|
5069
5059
|
scaleChange() {
|
|
5070
5060
|
this.scaleChanged = true;
|
|
5071
5061
|
this._scaleOrRotationChange();
|
|
@@ -5077,6 +5067,9 @@ class LeafLayout {
|
|
|
5077
5067
|
}
|
|
5078
5068
|
_scaleOrRotationChange() {
|
|
5079
5069
|
this.affectScaleOrRotation = true;
|
|
5070
|
+
this.matrixChange();
|
|
5071
|
+
}
|
|
5072
|
+
matrixChange() {
|
|
5080
5073
|
this.matrixChanged = true;
|
|
5081
5074
|
this.localBoxChanged || this.localBoxChange();
|
|
5082
5075
|
}
|
|
@@ -5219,10 +5212,11 @@ function __getListenerMap(eventer, capture, create) {
|
|
|
5219
5212
|
const LeafDataProxy = {
|
|
5220
5213
|
__setAttr(name, newValue) {
|
|
5221
5214
|
if (this.leafer && this.leafer.created) {
|
|
5222
|
-
|
|
5215
|
+
const oldValue = this.__.__getInput(name);
|
|
5216
|
+
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
5223
5217
|
this.__[name] = newValue;
|
|
5224
5218
|
const { CHANGE } = PropertyEvent;
|
|
5225
|
-
const event = new PropertyEvent(CHANGE, this, name,
|
|
5219
|
+
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
5226
5220
|
if (this.hasEvent(CHANGE) && !this.isLeafer)
|
|
5227
5221
|
this.emitEvent(event);
|
|
5228
5222
|
this.leafer.emitEvent(event);
|
|
@@ -5313,17 +5307,17 @@ const LeafMatrix = {
|
|
|
5313
5307
|
}
|
|
5314
5308
|
}
|
|
5315
5309
|
}
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5310
|
+
const { x, y, around } = this.__;
|
|
5311
|
+
r.e = x;
|
|
5312
|
+
r.f = y;
|
|
5313
|
+
if (around) {
|
|
5314
|
+
const { width, height } = this.__;
|
|
5315
|
+
if (width && height) {
|
|
5321
5316
|
const origin = (around === 'center') ? defaultCenter : around;
|
|
5322
5317
|
const offsetX = width * origin.x, offsetY = height * origin.y;
|
|
5323
5318
|
r.e -= offsetX * r.a + offsetY * r.c;
|
|
5324
5319
|
r.f -= offsetX * r.b + offsetY * r.d;
|
|
5325
5320
|
}
|
|
5326
|
-
layout.positionChanged = false;
|
|
5327
5321
|
}
|
|
5328
5322
|
this.__layout.matrixChanged = false;
|
|
5329
5323
|
}
|
|
@@ -5418,7 +5412,7 @@ const LeafBounds = {
|
|
|
5418
5412
|
data.__naturalWidth = layout.boxBounds.width;
|
|
5419
5413
|
data.__naturalHeight = layout.boxBounds.height;
|
|
5420
5414
|
if (this.around) {
|
|
5421
|
-
layout.
|
|
5415
|
+
layout.matrixChanged = true;
|
|
5422
5416
|
this.__updateWorldMatrix();
|
|
5423
5417
|
}
|
|
5424
5418
|
},
|
|
@@ -5459,7 +5453,7 @@ const LeafRender = {
|
|
|
5459
5453
|
const tempCanvas = canvas.getSameCanvas(true);
|
|
5460
5454
|
this.__draw(tempCanvas, options);
|
|
5461
5455
|
const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
|
|
5462
|
-
if (
|
|
5456
|
+
if (this.__hasMirror || options.matrix) {
|
|
5463
5457
|
canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
|
|
5464
5458
|
}
|
|
5465
5459
|
else {
|
|
@@ -5528,7 +5522,12 @@ const BranchRender = {
|
|
|
5528
5522
|
this.__renderBranch(tempCanvas, options);
|
|
5529
5523
|
canvas.opacity = this.__worldOpacity;
|
|
5530
5524
|
const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
|
|
5531
|
-
|
|
5525
|
+
if (this.__hasMirror || options.matrix) {
|
|
5526
|
+
canvas.copyWorld(tempCanvas, null, null, blendMode);
|
|
5527
|
+
}
|
|
5528
|
+
else {
|
|
5529
|
+
canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
|
|
5530
|
+
}
|
|
5532
5531
|
tempCanvas.recycle();
|
|
5533
5532
|
}
|
|
5534
5533
|
else {
|
|
@@ -5601,11 +5600,16 @@ exports.Leaf = class Leaf {
|
|
|
5601
5600
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5602
5601
|
constructor(data) {
|
|
5603
5602
|
this.innerId = create(LEAF);
|
|
5603
|
+
this.reset(data);
|
|
5604
|
+
}
|
|
5605
|
+
reset(data) {
|
|
5604
5606
|
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 };
|
|
5605
5607
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
5606
5608
|
this.__worldOpacity = 1;
|
|
5607
5609
|
this.__ = new this.__DataProcessor(this);
|
|
5608
5610
|
this.__layout = new this.__LayoutProcessor(this);
|
|
5611
|
+
if (this.__level)
|
|
5612
|
+
this.resetCustom();
|
|
5609
5613
|
if (data) {
|
|
5610
5614
|
if (data.children) {
|
|
5611
5615
|
this.set(data);
|
|
@@ -5615,6 +5619,10 @@ exports.Leaf = class Leaf {
|
|
|
5615
5619
|
}
|
|
5616
5620
|
}
|
|
5617
5621
|
}
|
|
5622
|
+
resetCustom() {
|
|
5623
|
+
this.__hasMask = this.__hasEraser = null;
|
|
5624
|
+
this.forceUpdate();
|
|
5625
|
+
}
|
|
5618
5626
|
waitParent(item) {
|
|
5619
5627
|
this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]);
|
|
5620
5628
|
}
|
|
@@ -5629,8 +5637,11 @@ exports.Leaf = class Leaf {
|
|
|
5629
5637
|
if (leafer !== null)
|
|
5630
5638
|
leafer = this;
|
|
5631
5639
|
}
|
|
5640
|
+
if (this.leafer && !leafer)
|
|
5641
|
+
this.leafer.leafs--;
|
|
5632
5642
|
this.leafer = leafer;
|
|
5633
5643
|
if (leafer) {
|
|
5644
|
+
leafer.leafs++;
|
|
5634
5645
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5635
5646
|
if (this.__leaferWait)
|
|
5636
5647
|
WaitHelper.run(this.__leaferWait);
|
|
@@ -5653,7 +5664,7 @@ exports.Leaf = class Leaf {
|
|
|
5653
5664
|
__getAttr(_attrName) { return undefined; }
|
|
5654
5665
|
forceUpdate(attrName) {
|
|
5655
5666
|
if (attrName === undefined)
|
|
5656
|
-
attrName = '
|
|
5667
|
+
attrName = 'width';
|
|
5657
5668
|
else if (attrName === 'surface')
|
|
5658
5669
|
attrName = 'blendMode';
|
|
5659
5670
|
const value = this.__.__getInput(attrName);
|
|
@@ -5860,7 +5871,7 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5860
5871
|
index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5861
5872
|
if (child.isBranch)
|
|
5862
5873
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5863
|
-
child.__layout.boundsChanged || child.__layout.
|
|
5874
|
+
child.__layout.boundsChanged || child.__layout.matrixChange();
|
|
5864
5875
|
if (child.__parentWait)
|
|
5865
5876
|
WaitHelper.run(child.__parentWait);
|
|
5866
5877
|
if (this.leafer) {
|
|
@@ -6050,7 +6061,6 @@ exports.Run = Run;
|
|
|
6050
6061
|
exports.StringNumberMap = StringNumberMap;
|
|
6051
6062
|
exports.TaskItem = TaskItem;
|
|
6052
6063
|
exports.TaskProcessor = TaskProcessor;
|
|
6053
|
-
exports.TransformEvent = TransformEvent;
|
|
6054
6064
|
exports.TwoPointBounds = TwoPointBounds;
|
|
6055
6065
|
exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|
|
6056
6066
|
exports.UICreator = UICreator;
|