@leafer-ui/core 1.5.2 → 1.6.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/lib/core.cjs +45 -29
- package/lib/core.cjs.map +1 -1
- package/lib/core.esm.js +45 -29
- package/lib/core.esm.js.map +1 -1
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +1 -1
- package/package.json +6 -6
package/lib/core.cjs
CHANGED
|
@@ -62,26 +62,25 @@ exports.App = class App extends draw.Leafer {
|
|
|
62
62
|
this.leafer = this;
|
|
63
63
|
this.watcher.disable();
|
|
64
64
|
this.layouter.disable();
|
|
65
|
-
this.__eventIds.push(this.on_(core.PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
66
65
|
}
|
|
67
66
|
start() {
|
|
68
67
|
super.start();
|
|
69
|
-
this.
|
|
68
|
+
this.forEach(leafer => leafer.start());
|
|
70
69
|
}
|
|
71
70
|
stop() {
|
|
72
|
-
this.
|
|
71
|
+
this.forEach(leafer => leafer.stop());
|
|
73
72
|
super.stop();
|
|
74
73
|
}
|
|
75
74
|
unlockLayout() {
|
|
76
75
|
super.unlockLayout();
|
|
77
|
-
this.
|
|
76
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
78
77
|
}
|
|
79
78
|
lockLayout() {
|
|
80
79
|
super.lockLayout();
|
|
81
|
-
this.
|
|
80
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
82
81
|
}
|
|
83
82
|
forceRender(bounds, sync) {
|
|
84
|
-
this.
|
|
83
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
85
84
|
}
|
|
86
85
|
addLeafer(merge) {
|
|
87
86
|
const leafer = new draw.Leafer(merge);
|
|
@@ -101,9 +100,8 @@ exports.App = class App extends draw.Leafer {
|
|
|
101
100
|
leafer.canvas.childIndex = index;
|
|
102
101
|
this.__listenChildEvents(leafer);
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
103
|
+
forEach(fn) {
|
|
104
|
+
this.children.forEach(fn);
|
|
107
105
|
}
|
|
108
106
|
__onCreated() {
|
|
109
107
|
this.created = this.children.every(child => child.created);
|
|
@@ -126,18 +124,18 @@ exports.App = class App extends draw.Leafer {
|
|
|
126
124
|
const m = options.matrix;
|
|
127
125
|
if (m)
|
|
128
126
|
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
129
|
-
this.
|
|
127
|
+
this.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
__onResize(event) {
|
|
133
|
-
this.
|
|
131
|
+
this.forEach(leafer => leafer.resize(event));
|
|
134
132
|
super.__onResize(event);
|
|
135
133
|
}
|
|
136
134
|
updateLayout() {
|
|
137
|
-
this.
|
|
135
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
138
136
|
}
|
|
139
137
|
__getChildConfig(userConfig) {
|
|
140
|
-
|
|
138
|
+
const config = Object.assign({}, this.config);
|
|
141
139
|
config.hittable = config.realCanvas = undefined;
|
|
142
140
|
if (userConfig)
|
|
143
141
|
core.DataHelper.assign(config, userConfig);
|
|
@@ -696,6 +694,7 @@ const config = {
|
|
|
696
694
|
delta: { x: 80 / 4, y: 8.0 },
|
|
697
695
|
},
|
|
698
696
|
pointer: {
|
|
697
|
+
snap: true,
|
|
699
698
|
hitRadius: 5,
|
|
700
699
|
tapTime: 120,
|
|
701
700
|
longPressTime: 800,
|
|
@@ -790,7 +789,7 @@ class InteractionBase {
|
|
|
790
789
|
if (this.downData) {
|
|
791
790
|
const canDrag = core.PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
|
|
792
791
|
if (canDrag) {
|
|
793
|
-
if (this.waitTap)
|
|
792
|
+
if (this.waitTap || this.longPressTimer)
|
|
794
793
|
this.pointerWaitCancel();
|
|
795
794
|
this.waitRightTap = false;
|
|
796
795
|
}
|
|
@@ -1051,7 +1050,10 @@ class InteractionBase {
|
|
|
1051
1050
|
}
|
|
1052
1051
|
getLocal(clientPoint, updateClient) {
|
|
1053
1052
|
const clientBounds = this.canvas.getClientBounds(updateClient);
|
|
1054
|
-
|
|
1053
|
+
const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
|
|
1054
|
+
if (this.p.snap)
|
|
1055
|
+
core.PointHelper.round(point);
|
|
1056
|
+
return point;
|
|
1055
1057
|
}
|
|
1056
1058
|
emitTap(data) {
|
|
1057
1059
|
this.emit(exports.PointerEvent.TAP, data);
|
|
@@ -1183,25 +1185,26 @@ const { toInnerRadiusPointOf, copy, setRadius } = core.PointHelper;
|
|
|
1183
1185
|
const inner = {};
|
|
1184
1186
|
const leaf = core.Leaf.prototype;
|
|
1185
1187
|
leaf.__hitWorld = function (point) {
|
|
1186
|
-
|
|
1188
|
+
const data = this.__;
|
|
1189
|
+
if (!data.hitSelf)
|
|
1187
1190
|
return false;
|
|
1188
|
-
|
|
1191
|
+
const world = this.__world, layout = this.__layout;
|
|
1192
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
1193
|
+
if (data.hitRadius) {
|
|
1189
1194
|
copy(inner, point), point = inner;
|
|
1190
|
-
setRadius(point,
|
|
1195
|
+
setRadius(point, data.hitRadius);
|
|
1191
1196
|
}
|
|
1192
|
-
toInnerRadiusPointOf(point,
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
if (this.__.hitBox || isSmall) {
|
|
1196
|
-
if (core.BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
1197
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
1198
|
+
if (data.hitBox || isSmall) {
|
|
1199
|
+
if (core.BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
1197
1200
|
return true;
|
|
1198
1201
|
if (isSmall)
|
|
1199
1202
|
return false;
|
|
1200
1203
|
}
|
|
1201
|
-
if (
|
|
1204
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
1202
1205
|
this.__updateHitCanvas();
|
|
1203
|
-
if (!
|
|
1204
|
-
|
|
1206
|
+
if (!layout.boundsChanged)
|
|
1207
|
+
layout.hitCanvasChanged = false;
|
|
1205
1208
|
}
|
|
1206
1209
|
return this.__hit(inner);
|
|
1207
1210
|
};
|
|
@@ -1214,7 +1217,9 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
|
1214
1217
|
const matrix = new core.Matrix();
|
|
1215
1218
|
const ui$1 = draw.UI.prototype;
|
|
1216
1219
|
ui$1.__updateHitCanvas = function () {
|
|
1217
|
-
|
|
1220
|
+
if (this.__box)
|
|
1221
|
+
this.__box.__updateHitCanvas();
|
|
1222
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
1218
1223
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
1219
1224
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
1220
1225
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -1228,9 +1233,9 @@ ui$1.__updateHitCanvas = function () {
|
|
|
1228
1233
|
const { x, y, width, height } = core.tempBounds.set(renderBounds).scale(scale);
|
|
1229
1234
|
h.resize({ width, height, pixelRatio: 1 });
|
|
1230
1235
|
h.clear();
|
|
1231
|
-
|
|
1236
|
+
core.ImageManager.patternLocked = true;
|
|
1232
1237
|
this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
|
|
1233
|
-
|
|
1238
|
+
core.ImageManager.patternLocked = false;
|
|
1234
1239
|
h.resetTransform();
|
|
1235
1240
|
data.__isHitPixel = true;
|
|
1236
1241
|
}
|
|
@@ -1241,6 +1246,8 @@ ui$1.__updateHitCanvas = function () {
|
|
|
1241
1246
|
h.setStrokeOptions(data);
|
|
1242
1247
|
};
|
|
1243
1248
|
ui$1.__hit = function (inner) {
|
|
1249
|
+
if (this.__box && this.__box.__hit(inner))
|
|
1250
|
+
return true;
|
|
1244
1251
|
const data = this.__;
|
|
1245
1252
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
1246
1253
|
return true;
|
|
@@ -1289,6 +1296,15 @@ rect.__hitFill = box.__hitFill = function (inner) {
|
|
|
1289
1296
|
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : core.BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
1290
1297
|
};
|
|
1291
1298
|
|
|
1299
|
+
draw.Text.prototype.__drawHitPath = function (canvas) {
|
|
1300
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
1301
|
+
canvas.beginPath();
|
|
1302
|
+
if (__letterSpacing < 0)
|
|
1303
|
+
this.__drawPathByBox(canvas);
|
|
1304
|
+
else
|
|
1305
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1292
1308
|
function getSelector(ui) {
|
|
1293
1309
|
return ui.leafer ? ui.leafer.selector : (draw.Platform.selector || (draw.Platform.selector = draw.Creator.selector()));
|
|
1294
1310
|
}
|