@leafer/display 1.7.0 → 1.9.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/package.json +12 -11
- package/src/Branch.ts +4 -3
- package/src/Leaf.ts +23 -4
- package/types/index.d.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "@leafer/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/math": "1.
|
|
26
|
-
"@leafer/data": "1.
|
|
27
|
-
"@leafer/layout": "1.
|
|
28
|
-
"@leafer/display-module": "1.
|
|
29
|
-
"@leafer/event": "1.
|
|
30
|
-
"@leafer/decorator": "1.
|
|
31
|
-
"@leafer/helper": "1.
|
|
32
|
-
"@leafer/
|
|
33
|
-
"@leafer/
|
|
25
|
+
"@leafer/math": "1.9.0",
|
|
26
|
+
"@leafer/data": "1.9.0",
|
|
27
|
+
"@leafer/layout": "1.9.0",
|
|
28
|
+
"@leafer/display-module": "1.9.0",
|
|
29
|
+
"@leafer/event": "1.9.0",
|
|
30
|
+
"@leafer/decorator": "1.9.0",
|
|
31
|
+
"@leafer/helper": "1.9.0",
|
|
32
|
+
"@leafer/image": "1.9.0",
|
|
33
|
+
"@leafer/debug": "1.9.0",
|
|
34
|
+
"@leafer/platform": "1.9.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@leafer/interface": "1.
|
|
37
|
+
"@leafer/interface": "1.9.0"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/src/Branch.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { BranchHelper, LeafBoundsHelper } from '@leafer/helper'
|
|
|
5
5
|
import { useModule } from '@leafer/decorator'
|
|
6
6
|
import { BranchRender } from '@leafer/display-module'
|
|
7
7
|
import { UICreator } from '@leafer/platform'
|
|
8
|
+
import { isArray, isUndefined } from '@leafer/data'
|
|
8
9
|
import { Debug } from '@leafer/debug'
|
|
9
10
|
|
|
10
11
|
import { Leaf } from './Leaf'
|
|
@@ -67,9 +68,9 @@ export class Branch extends Leaf { // tip: rewrited Group
|
|
|
67
68
|
public add(child: ILeaf, index?: number): void {
|
|
68
69
|
if (child === this || child.destroyed) return debug.warn('add self or destroyed')
|
|
69
70
|
|
|
70
|
-
const noIndex = index
|
|
71
|
+
const noIndex = isUndefined(index)
|
|
71
72
|
if (!child.__) {
|
|
72
|
-
if (child
|
|
73
|
+
if (isArray(child)) return child.forEach(item => { this.add(item, index); noIndex || index++ }) // add []
|
|
73
74
|
else child = UICreator.get(child.tag, child) // add JSON
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -105,7 +106,7 @@ export class Branch extends Leaf { // tip: rewrited Group
|
|
|
105
106
|
|
|
106
107
|
} else this.find(child as any).forEach(item => this.remove(item, destroy)) //
|
|
107
108
|
|
|
108
|
-
} else if (child
|
|
109
|
+
} else if (isUndefined(child)) {
|
|
109
110
|
super.remove(null, destroy)
|
|
110
111
|
}
|
|
111
112
|
}
|
package/src/Leaf.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData, IMatrixWithScaleData, IAlign, IJSONOptions, IEventParamsMap, IEventOption, IAxis, IMotionPathData, IUnitData, IRotationPointData, ITransition, IValueFunction, IEventParams } from '@leafer/interface'
|
|
1
|
+
import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData, IMatrixWithScaleData, IAlign, IJSONOptions, IEventParamsMap, IEventOption, IAxis, IMotionPathData, IUnitData, IRotationPointData, ITransition, IValueFunction, IEventParams, IScaleData, IScaleFixed } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
|
|
3
|
-
import { LeafData } from '@leafer/data'
|
|
3
|
+
import { LeafData, isUndefined } from '@leafer/data'
|
|
4
4
|
import { LeafLayout } from '@leafer/layout'
|
|
5
5
|
import { LeafDataProxy, LeafMatrix, LeafBounds, LeafEventer, LeafRender } from '@leafer/display-module'
|
|
6
6
|
import { boundsType, useModule, defineDataProcessor } from '@leafer/decorator'
|
|
7
7
|
import { LeafHelper } from '@leafer/helper'
|
|
8
8
|
import { ChildEvent } from '@leafer/event'
|
|
9
|
+
import { ImageManager } from '@leafer/image'
|
|
9
10
|
import { Plugin } from '@leafer/debug'
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
const tempScaleData = {} as IScaleData
|
|
12
14
|
const { LEAF, create } = IncrementId
|
|
13
15
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper
|
|
14
16
|
const { toOuterOf } = BoundsHelper
|
|
@@ -245,10 +247,10 @@ export class Leaf implements ILeaf {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
public forceUpdate(attrName?: string): void {
|
|
248
|
-
if (attrName
|
|
250
|
+
if (isUndefined(attrName)) attrName = 'width'
|
|
249
251
|
else if (attrName === 'surface') attrName = 'blendMode'
|
|
250
252
|
const value = this.__.__getInput(attrName);
|
|
251
|
-
(this.__ as any)[attrName] = value
|
|
253
|
+
(this.__ as any)[attrName] = isUndefined(value) ? null : undefined;
|
|
252
254
|
(this as any)[attrName] = value
|
|
253
255
|
}
|
|
254
256
|
|
|
@@ -347,6 +349,21 @@ export class Leaf implements ILeaf {
|
|
|
347
349
|
}
|
|
348
350
|
}
|
|
349
351
|
|
|
352
|
+
public getClampRenderScale(): number {
|
|
353
|
+
let { scaleX } = this.__nowWorld || this.__world
|
|
354
|
+
if (scaleX < 0) scaleX = -scaleX
|
|
355
|
+
return scaleX > 1 ? scaleX : 1
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed): IScaleData {
|
|
359
|
+
let { scaleX, scaleY } = ImageManager.patternLocked ? this.__world : this.__nowWorld
|
|
360
|
+
if (abs) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY)
|
|
361
|
+
if (scaleFixed === true || (scaleFixed === 'zoom-in' && scaleX > 1 && scaleY > 1)) scaleX = scaleY = 1
|
|
362
|
+
tempScaleData.scaleX = scaleX
|
|
363
|
+
tempScaleData.scaleY = scaleY
|
|
364
|
+
return tempScaleData
|
|
365
|
+
}
|
|
366
|
+
|
|
350
367
|
public getTransform(relative?: ILocationType | ILeaf): IMatrixData {
|
|
351
368
|
return this.__layout.getTransform(relative || 'local')
|
|
352
369
|
}
|
|
@@ -541,6 +558,8 @@ export class Leaf implements ILeaf {
|
|
|
541
558
|
|
|
542
559
|
// @leafer-ui/hit LeafHit rewrite
|
|
543
560
|
|
|
561
|
+
public hit(_world: IPointData, _hitRadius?: number): boolean { return true }
|
|
562
|
+
|
|
544
563
|
public __hitWorld(_point: IRadiusPointData): boolean { return true }
|
|
545
564
|
|
|
546
565
|
public __hit(_local: IRadiusPointData): boolean { return true }
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IMatrixWithScaleData, IHitCanvas, IEventParamsMap, IEventListenerMap, ILeafInputData, IFunction, IObject, IValue, IJSONOptions, IFindMethod, ILeaferCanvas, IRenderOptions, ILocationType, IBoundsType, ILayoutBoundsData, IPointData, ITransition, IAlign, IAxis, IRadiusPointData, IMotionPathData, IUnitData, IRotationPointData, IEventParams, IEventListener, IEventOption, IEventListenerId, IEvent, IValueFunction, IAttrDecorator } from '@leafer/interface';
|
|
1
|
+
import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IMatrixWithScaleData, IHitCanvas, IEventParamsMap, IEventListenerMap, ILeafInputData, IFunction, IObject, IValue, IJSONOptions, IFindMethod, ILeaferCanvas, IRenderOptions, IScaleFixed, IScaleData, ILocationType, IBoundsType, ILayoutBoundsData, IPointData, ITransition, IAlign, IAxis, IRadiusPointData, IMotionPathData, IUnitData, IRotationPointData, IEventParams, IEventListener, IEventOption, IEventListenerId, IEvent, IValueFunction, IAttrDecorator } from '@leafer/interface';
|
|
2
2
|
import { LeafData } from '@leafer/data';
|
|
3
3
|
import { LeafLayout } from '@leafer/layout';
|
|
4
4
|
|
|
@@ -108,6 +108,8 @@ declare class Leaf implements ILeaf {
|
|
|
108
108
|
__updateMask(_value?: boolean): void;
|
|
109
109
|
__renderMask(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
110
110
|
__getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData;
|
|
111
|
+
getClampRenderScale(): number;
|
|
112
|
+
getRenderScaleData(abs?: boolean, scaleFixed?: IScaleFixed): IScaleData;
|
|
111
113
|
getTransform(relative?: ILocationType | ILeaf): IMatrixData;
|
|
112
114
|
getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
|
|
113
115
|
getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
|
|
@@ -146,6 +148,7 @@ declare class Leaf implements ILeaf {
|
|
|
146
148
|
__scaleResize(_scaleX: number, _scaleY: number): void;
|
|
147
149
|
resizeWidth(_width: number): void;
|
|
148
150
|
resizeHeight(_height: number): void;
|
|
151
|
+
hit(_world: IPointData, _hitRadius?: number): boolean;
|
|
149
152
|
__hitWorld(_point: IRadiusPointData): boolean;
|
|
150
153
|
__hit(_local: IRadiusPointData): boolean;
|
|
151
154
|
__hitFill(_inner: IRadiusPointData): boolean;
|