leafer-ui 1.0.0-rc.26 → 1.0.0-rc.27
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/README.md +7 -3
- package/dist/web.js +58 -41
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +58 -41
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -4,14 +4,18 @@ Leafer UI 是基于 [Leafer](https://github.com/leaferjs/leafer) 开发的一套
|
|
|
4
4
|
|
|
5
5
|
提供了常用的 UI 绘图组件,和开箱即用的功能,方便与 Figma、Sketch 等产品进行数据交换,并为跨平台开发提供了统一、丰富的交互事件,如拖拽、旋转、缩放手势等。
|
|
6
6
|
|
|
7
|
-
1.0.0-rc.
|
|
7
|
+
1.0.0-rc.27 已发布 🎉🎉🎉,查看 [更新日志](https://leaferjs.com/ui/update/)。
|
|
8
8
|
|
|
9
9
|
目前产品已经逐步稳定,正式版即将到来,感谢所有参与的朋友们~
|
|
10
10
|
|
|
11
|
-
想马上开始使用,请查看 [快速安装](https://leaferjs.com/ui/guide/start.html), 有问题、建议可以 [提交到这里](https://github.com/leaferjs/ui/issues),或加入[技术交流群](https://leaferjs.com/ui/guide/)。
|
|
12
|
-
|
|
13
11
|
如果您仅需绘图功能,推荐更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/type/draw/start.html) (46KB min+gzip)。
|
|
14
12
|
|
|
13
|
+
如果您想编辑控制图形,需安装 [图形编辑器](https://leaferjs.com/guide/plugin/editor/index.md) 插件。
|
|
14
|
+
|
|
15
|
+
## 互动交流
|
|
16
|
+
|
|
17
|
+
想马上开始使用,请查看 [快速安装](https://leaferjs.com/ui/guide/start.html), 有问题、建议可以 [提交到这里](https://github.com/leaferjs/ui/issues),或加入 [技术交流群](https://leaferjs.com/#contact)。
|
|
18
|
+
|
|
15
19
|
🌟 记得前往 [GitHub](https://github.com/leaferjs/ui) / [Gitee](https://gitee.com/leaferjs/ui) 点亮你的 [小星星](https://github.com/leaferjs/ui) ✨ ✨ ✨
|
|
16
20
|
|
|
17
21
|
## 使命与愿景
|
package/dist/web.js
CHANGED
|
@@ -5192,6 +5192,9 @@ var LeaferUI = (function (exports) {
|
|
|
5192
5192
|
}
|
|
5193
5193
|
set(_data) { }
|
|
5194
5194
|
get(_name) { return undefined; }
|
|
5195
|
+
setAttr(name, value) { this[name] = value; }
|
|
5196
|
+
getAttr(name) { return this[name]; }
|
|
5197
|
+
getComputedAttr(name) { return this.__[name]; }
|
|
5195
5198
|
toJSON() {
|
|
5196
5199
|
return this.__.__getInputData();
|
|
5197
5200
|
}
|
|
@@ -5752,7 +5755,7 @@ var LeaferUI = (function (exports) {
|
|
|
5752
5755
|
}
|
|
5753
5756
|
}
|
|
5754
5757
|
|
|
5755
|
-
const version = "1.0.0-rc.
|
|
5758
|
+
const version = "1.0.0-rc.27";
|
|
5756
5759
|
const inviteCode = {};
|
|
5757
5760
|
|
|
5758
5761
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
@@ -7227,6 +7230,8 @@ var LeaferUI = (function (exports) {
|
|
|
7227
7230
|
this.__drawRenderPath(canvas);
|
|
7228
7231
|
if (fill && !ignoreFill)
|
|
7229
7232
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7233
|
+
if (this.__.__isCanvas)
|
|
7234
|
+
this.__drawAfterFill(canvas, options);
|
|
7230
7235
|
if (stroke && !ignoreStroke)
|
|
7231
7236
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7232
7237
|
}
|
|
@@ -7649,6 +7654,9 @@ var LeaferUI = (function (exports) {
|
|
|
7649
7654
|
__decorate([
|
|
7650
7655
|
dataType()
|
|
7651
7656
|
], exports.UI.prototype, "disabledStyle", void 0);
|
|
7657
|
+
__decorate([
|
|
7658
|
+
dataType({})
|
|
7659
|
+
], exports.UI.prototype, "data", void 0);
|
|
7652
7660
|
__decorate([
|
|
7653
7661
|
rewrite(exports.Leaf.prototype.reset)
|
|
7654
7662
|
], exports.UI.prototype, "reset", null);
|
|
@@ -8491,7 +8499,7 @@ var LeaferUI = (function (exports) {
|
|
|
8491
8499
|
super(data);
|
|
8492
8500
|
this.canvas = Creator.canvas(this.__);
|
|
8493
8501
|
this.context = this.canvas.context;
|
|
8494
|
-
this.__.__drawAfterFill = true;
|
|
8502
|
+
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8495
8503
|
}
|
|
8496
8504
|
draw(ui, offset, scale, rotation) {
|
|
8497
8505
|
ui.__layout.update();
|
|
@@ -8559,9 +8567,6 @@ var LeaferUI = (function (exports) {
|
|
|
8559
8567
|
__decorate([
|
|
8560
8568
|
resizeType()
|
|
8561
8569
|
], exports.Canvas.prototype, "contextSettings", void 0);
|
|
8562
|
-
__decorate([
|
|
8563
|
-
hitType('all')
|
|
8564
|
-
], exports.Canvas.prototype, "hitFill", void 0);
|
|
8565
8570
|
exports.Canvas = __decorate([
|
|
8566
8571
|
registerUI()
|
|
8567
8572
|
], exports.Canvas);
|
|
@@ -9028,20 +9033,32 @@ var LeaferUI = (function (exports) {
|
|
|
9028
9033
|
move.x = 0;
|
|
9029
9034
|
return move;
|
|
9030
9035
|
}
|
|
9031
|
-
static getMoveInDragBounds(
|
|
9032
|
-
const x =
|
|
9033
|
-
const right = x +
|
|
9036
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9037
|
+
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9038
|
+
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9034
9039
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9035
9040
|
if (!change)
|
|
9036
9041
|
move = Object.assign({}, move);
|
|
9037
|
-
if (
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9042
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9043
|
+
if (x > dragBounds.x)
|
|
9044
|
+
move.x += dragBounds.x - x;
|
|
9045
|
+
else if (right < boundsRight)
|
|
9046
|
+
move.x += boundsRight - right;
|
|
9047
|
+
if (y > dragBounds.y)
|
|
9048
|
+
move.y += dragBounds.y - y;
|
|
9049
|
+
else if (bottom < boundsBottom)
|
|
9050
|
+
move.y += boundsBottom - bottom;
|
|
9051
|
+
}
|
|
9052
|
+
else {
|
|
9053
|
+
if (x < dragBounds.x)
|
|
9054
|
+
move.x += dragBounds.x - x;
|
|
9055
|
+
else if (right > boundsRight)
|
|
9056
|
+
move.x += boundsRight - right;
|
|
9057
|
+
if (y < dragBounds.y)
|
|
9058
|
+
move.y += dragBounds.y - y;
|
|
9059
|
+
else if (bottom > boundsBottom)
|
|
9060
|
+
move.y += boundsBottom - bottom;
|
|
9061
|
+
}
|
|
9045
9062
|
return move;
|
|
9046
9063
|
}
|
|
9047
9064
|
getPageMove(total) {
|
|
@@ -10161,27 +10178,6 @@ var LeaferUI = (function (exports) {
|
|
|
10161
10178
|
}
|
|
10162
10179
|
}
|
|
10163
10180
|
|
|
10164
|
-
const canvas$1 = LeaferCanvasBase.prototype;
|
|
10165
|
-
canvas$1.hitFill = function (point, fillRule) {
|
|
10166
|
-
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
10167
|
-
};
|
|
10168
|
-
canvas$1.hitStroke = function (point, strokeWidth) {
|
|
10169
|
-
this.strokeWidth = strokeWidth;
|
|
10170
|
-
return this.context.isPointInStroke(point.x, point.y);
|
|
10171
|
-
};
|
|
10172
|
-
canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
10173
|
-
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
10174
|
-
if (offset)
|
|
10175
|
-
x -= offset.x, y -= offset.y;
|
|
10176
|
-
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
10177
|
-
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
10178
|
-
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
10179
|
-
if (data[i + 3] > 0)
|
|
10180
|
-
return true;
|
|
10181
|
-
}
|
|
10182
|
-
return data[3] > 0;
|
|
10183
|
-
};
|
|
10184
|
-
|
|
10185
10181
|
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
10186
10182
|
const inner = {};
|
|
10187
10183
|
const leaf = exports.Leaf.prototype;
|
|
@@ -10218,7 +10214,7 @@ var LeaferUI = (function (exports) {
|
|
|
10218
10214
|
const ui$2 = exports.UI.prototype;
|
|
10219
10215
|
ui$2.__updateHitCanvas = function () {
|
|
10220
10216
|
const data = this.__, { hitCanvasManager } = this.leafer;
|
|
10221
|
-
const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
|
|
10217
|
+
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10222
10218
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10223
10219
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
10224
10220
|
if (!this.__hitCanvas)
|
|
@@ -10250,11 +10246,11 @@ var LeaferUI = (function (exports) {
|
|
|
10250
10246
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10251
10247
|
return true;
|
|
10252
10248
|
const { hitFill } = data;
|
|
10253
|
-
const needHitFillPath = (data.fill && hitFill
|
|
10249
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
10254
10250
|
if (needHitFillPath && this.__hitFill(inner))
|
|
10255
10251
|
return true;
|
|
10256
10252
|
const { hitStroke, __strokeWidth } = data;
|
|
10257
|
-
const needHitStrokePath = (data.stroke &&
|
|
10253
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
|
|
10258
10254
|
if (!needHitFillPath && !needHitStrokePath)
|
|
10259
10255
|
return false;
|
|
10260
10256
|
const radiusWidth = inner.radiusX * 2;
|
|
@@ -10286,7 +10282,7 @@ var LeaferUI = (function (exports) {
|
|
|
10286
10282
|
const ui$1 = new exports.UI();
|
|
10287
10283
|
const rect = exports.Rect.prototype;
|
|
10288
10284
|
rect.__updateHitCanvas = function () {
|
|
10289
|
-
if (this.stroke || this.cornerRadius || (this.fill && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10285
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10290
10286
|
ui$1.__updateHitCanvas.call(this);
|
|
10291
10287
|
else if (this.__hitCanvas)
|
|
10292
10288
|
this.__hitCanvas = null;
|
|
@@ -10309,6 +10305,27 @@ var LeaferUI = (function (exports) {
|
|
|
10309
10305
|
return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
|
|
10310
10306
|
};
|
|
10311
10307
|
|
|
10308
|
+
const canvas$1 = LeaferCanvasBase.prototype;
|
|
10309
|
+
canvas$1.hitFill = function (point, fillRule) {
|
|
10310
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
10311
|
+
};
|
|
10312
|
+
canvas$1.hitStroke = function (point, strokeWidth) {
|
|
10313
|
+
this.strokeWidth = strokeWidth;
|
|
10314
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
10315
|
+
};
|
|
10316
|
+
canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
10317
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
10318
|
+
if (offset)
|
|
10319
|
+
x -= offset.x, y -= offset.y;
|
|
10320
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
10321
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
10322
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
10323
|
+
if (data[i + 3] > 0)
|
|
10324
|
+
return true;
|
|
10325
|
+
}
|
|
10326
|
+
return data[3] > 0;
|
|
10327
|
+
};
|
|
10328
|
+
|
|
10312
10329
|
const PointerEventHelper = {
|
|
10313
10330
|
convert(e, local) {
|
|
10314
10331
|
const base = InteractionHelper.getBase(e);
|