@leafer/helper
Advanced tools
+5
-4
| { | ||
| "name": "@leafer/helper", | ||
| "version": "1.8.0", | ||
| "version": "1.9.0", | ||
| "description": "@leafer/helper", | ||
@@ -25,8 +25,9 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/math": "1.8.0", | ||
| "@leafer/platform": "1.8.0" | ||
| "@leafer/data": "1.9.0", | ||
| "@leafer/math": "1.9.0", | ||
| "@leafer/platform": "1.9.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.8.0" | ||
| "@leafer/interface": "1.9.0" | ||
| } | ||
| } |
| import { ILeaf, ILeafLevelList, ILeafList } from '@leafer/interface' | ||
| import { isUndefined } from '@leafer/data' | ||
| import { LeafHelper } from './LeafHelper' | ||
@@ -35,3 +35,3 @@ | ||
| while (leaf.parent) { | ||
| if (keys[leaf.parent.innerId] === undefined) { | ||
| if (isUndefined(keys[leaf.parent.innerId])) { | ||
| leafList.add(leaf.parent) | ||
@@ -38,0 +38,0 @@ leaf = leaf.parent |
@@ -22,12 +22,12 @@ import { ILeaf, IBoundsData, IRenderOptions } from '@leafer/interface' | ||
| maskLocalBoxBounds(target: ILeaf): IBoundsData { | ||
| return target.__.mask ? target.__localBoxBounds : null | ||
| maskLocalBoxBounds(target: ILeaf, index: number): IBoundsData { | ||
| return checkMask(target, index) && target.__localBoxBounds | ||
| }, | ||
| maskLocalStrokeBounds(target: ILeaf): IBoundsData { | ||
| return target.__.mask ? target.__layout.localStrokeBounds : null | ||
| maskLocalStrokeBounds(target: ILeaf, index: number): IBoundsData { | ||
| return checkMask(target, index) && target.__layout.localStrokeBounds | ||
| }, | ||
| maskLocalRenderBounds(target: ILeaf): IBoundsData { | ||
| return target.__.mask ? target.__layout.localRenderBounds : null | ||
| maskLocalRenderBounds(target: ILeaf, index: number): IBoundsData { | ||
| return checkMask(target, index) && target.__layout.localRenderBounds | ||
| }, | ||
@@ -42,1 +42,10 @@ | ||
| } | ||
| let findMask: number | ||
| function checkMask(target: ILeaf, index: number): boolean { | ||
| if (!index) findMask = 0 | ||
| if (target.__.mask) findMask = 1 | ||
| return findMask < 0 ? null : (findMask && (findMask = -1), true) // 第一个 mask 元素之后的元素 bounds 可以忽略,返回 null | ||
| } |
+22
-3
| import { IAlign, ILeaf, IMatrixData, IPointData, IAxis, ITransition, ILeaferCanvas, IBoundsData, IMatrixWithBoundsData } from '@leafer/interface' | ||
| import { MathHelper, MatrixHelper, PointHelper, AroundHelper, getMatrixData, BoundsHelper } from '@leafer/math' | ||
| import { Platform } from '@leafer/platform' | ||
| import { isObject, isNumber } from '@leafer/data' | ||
@@ -82,2 +83,6 @@ | ||
| draggable(t: ILeaf): boolean { | ||
| return (t.draggable || t.editable) && t.hitSelf && !t.locked | ||
| }, | ||
| copyCanvasByWorld(leaf: ILeaf, currentCanvas: ILeaferCanvas, fromCanvas: ILeaferCanvas, fromWorld?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void { | ||
@@ -92,3 +97,3 @@ if (!fromWorld) fromWorld = leaf.__nowWorld | ||
| moveWorld(t: ILeaf, x: number | IPointData, y = 0, isInnerPoint?: boolean, transition?: ITransition): void { | ||
| const local = typeof x === 'object' ? { ...x } : { x, y } | ||
| const local = isObject(x) ? { ...x } : { x, y } | ||
| isInnerPoint ? toOuterPoint(t.localTransform, local, local, true) : (t.parent && toInnerPoint(t.parent.worldTransform, local, local, true)) | ||
@@ -99,3 +104,3 @@ L.moveLocal(t, local.x, local.y, transition) | ||
| moveLocal(t: ILeaf, x: number | IPointData, y = 0, transition?: ITransition): void { | ||
| if (typeof x === 'object') y = x.y, x = x.x | ||
| if (isObject(x)) y = x.y, x = x.x | ||
| x += t.x | ||
@@ -113,3 +118,3 @@ y += t.y | ||
| const o = t.__localMatrix | ||
| if (typeof scaleY !== 'number') { | ||
| if (!isNumber(scaleY)) { | ||
| if (scaleY) transition = scaleY | ||
@@ -217,2 +222,16 @@ scaleY = scaleX | ||
| } | ||
| }, | ||
| // 简单动画操作 | ||
| animateMove(t: ILeaf, move: IPointData, speed = 0.3) { | ||
| if (!move.x && !move.y) return | ||
| if (Math.abs(move.x) < 1 && Math.abs(move.y) < 1) { | ||
| t.move(move) | ||
| } else { | ||
| const x = move.x * speed, y = move.y * speed | ||
| move.x -= x, move.y -= y | ||
| t.move(x, y) | ||
| Platform.requestRender(() => L.animateMove(t, move, speed)) | ||
| } | ||
| } | ||
@@ -219,0 +238,0 @@ |
+5
-3
@@ -11,2 +11,3 @@ import { ILeaf, ILeaferCanvas, IBoundsData, IPointData, ITransition, IMatrixData, IAxis, IAlign, IRenderOptions, ILeafList, ILeafLevelList, IFunction } from '@leafer/interface'; | ||
| worldHittable(t: ILeaf): boolean; | ||
| draggable(t: ILeaf): boolean; | ||
| copyCanvasByWorld(leaf: ILeaf, currentCanvas: ILeaferCanvas, fromCanvas: ILeaferCanvas, fromWorld?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void; | ||
@@ -30,2 +31,3 @@ moveWorld(t: ILeaf, x: number | IPointData, y?: number, isInnerPoint?: boolean, transition?: ITransition): void; | ||
| hasParent(p: ILeaf, parent: ILeaf): boolean | void; | ||
| animateMove(t: ILeaf, move: IPointData, speed?: number): void; | ||
| }; | ||
@@ -38,5 +40,5 @@ | ||
| localRenderBounds(target: ILeaf): IBoundsData; | ||
| maskLocalBoxBounds(target: ILeaf): IBoundsData; | ||
| maskLocalStrokeBounds(target: ILeaf): IBoundsData; | ||
| maskLocalRenderBounds(target: ILeaf): IBoundsData; | ||
| maskLocalBoxBounds(target: ILeaf, index: number): IBoundsData; | ||
| maskLocalStrokeBounds(target: ILeaf, index: number): IBoundsData; | ||
| maskLocalRenderBounds(target: ILeaf, index: number): IBoundsData; | ||
| excludeRenderBounds(child: ILeaf, options: IRenderOptions): boolean; | ||
@@ -43,0 +45,0 @@ }; |
20361
5.91%369
6.96%3
50%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated