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