@leafer/display 1.0.0-rc.25 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display",
3
- "version": "1.0.0-rc.25",
3
+ "version": "1.0.0-rc.27",
4
4
  "description": "@leafer/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,16 +22,16 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.0-rc.25",
26
- "@leafer/data": "1.0.0-rc.25",
27
- "@leafer/layout": "1.0.0-rc.25",
28
- "@leafer/display-module": "1.0.0-rc.25",
29
- "@leafer/event": "1.0.0-rc.25",
30
- "@leafer/decorator": "1.0.0-rc.25",
31
- "@leafer/helper": "1.0.0-rc.25",
32
- "@leafer/platform": "1.0.0-rc.25"
25
+ "@leafer/math": "1.0.0-rc.27",
26
+ "@leafer/data": "1.0.0-rc.27",
27
+ "@leafer/layout": "1.0.0-rc.27",
28
+ "@leafer/display-module": "1.0.0-rc.27",
29
+ "@leafer/event": "1.0.0-rc.27",
30
+ "@leafer/decorator": "1.0.0-rc.27",
31
+ "@leafer/helper": "1.0.0-rc.27",
32
+ "@leafer/platform": "1.0.0-rc.27"
33
33
  },
34
34
  "devDependencies": {
35
- "@leafer/interface": "1.0.0-rc.25"
35
+ "@leafer/interface": "1.0.0-rc.27"
36
36
  }
37
37
  }
package/src/Leaf.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, ILayoutAttr, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData, IMatrixWithScaleData } from '@leafer/interface'
1
+ import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, ILayoutAttr, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData, IMatrixWithScaleData, IAlign } from '@leafer/interface'
2
2
  import { BoundsHelper, IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
3
3
  import { LeafData } from '@leafer/data'
4
4
  import { LeafLayout } from '@leafer/layout'
@@ -11,8 +11,8 @@ import { ChildEvent } from '@leafer/event'
11
11
  const { LEAF, create } = IncrementId
12
12
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper
13
13
  const { toOuterOf } = BoundsHelper
14
- const { tempToOuterOf, copy } = PointHelper
15
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper
14
+ const { copy } = PointHelper
15
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper
16
16
 
17
17
  @useModule(LeafDataProxy)
18
18
  @useModule(LeafMatrix)
@@ -173,6 +173,11 @@ export class Leaf implements ILeaf {
173
173
  public set(_data: IObject): void { }
174
174
  public get(_name?: string): ILeafInputData | IValue { return undefined }
175
175
 
176
+ public setAttr(name: string, value: any): void { (this as IObject)[name] = value }
177
+ public getAttr(name: string): any { return (this as IObject)[name] }
178
+
179
+ public getComputedAttr(name: string): any { return (this.__ as IObject)[name] }
180
+
176
181
  public toJSON(): IObject {
177
182
  return this.__.__getInputData()
178
183
  }
@@ -181,6 +186,12 @@ export class Leaf implements ILeaf {
181
186
  return JSON.stringify(this.toJSON())
182
187
  }
183
188
 
189
+ public toSVG(): string { return undefined }
190
+
191
+ public __SVG(_data: IObject): void { }
192
+
193
+ public toHTML(): string { return undefined }
194
+
184
195
  // LeafDataProxy rewrite
185
196
 
186
197
  public __setAttr(_attrName: string, _newValue: IValue): boolean { return true }
@@ -200,9 +211,9 @@ export class Leaf implements ILeaf {
200
211
 
201
212
  public findTag(_tag: string | string[]): ILeaf[] { return undefined }
202
213
 
203
- public findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf { return undefined }
214
+ public findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf | undefined { return undefined }
204
215
 
205
- public findId(_id: number | string): ILeaf { return undefined }
216
+ public findId(_id: number | string): ILeaf | undefined { return undefined }
206
217
 
207
218
  // ---
208
219
 
@@ -435,19 +446,18 @@ export class Leaf implements ILeaf {
435
446
  moveLocal(this, x, y)
436
447
  }
437
448
 
438
- public scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void {
439
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize)
449
+ public scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void {
450
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize)
440
451
  }
441
452
 
442
- public rotateOf(origin: IPointData, rotation: number): void {
443
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation)
453
+ public rotateOf(origin: IPointData | IAlign, rotation: number): void {
454
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation)
444
455
  }
445
456
 
446
- public skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void {
447
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize)
457
+ public skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void {
458
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize)
448
459
  }
449
460
 
450
-
451
461
  public transformWorld(worldTransform?: IMatrixData, resize?: boolean): void {
452
462
  transformWorld(this, worldTransform, resize)
453
463
  }
@@ -469,7 +479,7 @@ export class Leaf implements ILeaf {
469
479
  }
470
480
 
471
481
 
472
- // @leafer-ui/scale rewrite
482
+ // @leafer-in/resize rewrite
473
483
 
474
484
  public scaleResize(scaleX: number, scaleY = scaleX, _noResize?: boolean): void {
475
485
  (this as ILeaf).scaleX *= scaleX;
@@ -478,6 +488,18 @@ export class Leaf implements ILeaf {
478
488
 
479
489
  public __scaleResize(_scaleX: number, _scaleY: number): void { }
480
490
 
491
+
492
+ public resizeWidth(width: number): void {
493
+ const scale = width / this.__localBoxBounds.width
494
+ this.scaleResize(scale, this.__.lockRatio ? scale : 1)
495
+ }
496
+
497
+ public resizeHeight(height: number): void {
498
+ const scale = height / this.__localBoxBounds.height
499
+ this.scaleResize(this.__.lockRatio ? scale : 1, scale)
500
+ }
501
+
502
+
481
503
  // @leafer-ui/hit LeafHit rewrite
482
504
 
483
505
  public __hitWorld(_point: 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, IEventListenerMap, IFunction, ILeafInputData, IObject, IValue, IFindMethod, ILeaferCanvas, IRenderOptions, ILayoutAttr, ILocationType, IBoundsType, ILayoutBoundsData, IPointData, IRadiusPointData, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IAttrDecorator } from '@leafer/interface';
1
+ import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IMatrixWithScaleData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, IValue, IFindMethod, ILeaferCanvas, IRenderOptions, ILayoutAttr, ILocationType, IBoundsType, ILayoutBoundsData, IPointData, IAlign, IRadiusPointData, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IAttrDecorator } from '@leafer/interface';
2
2
  import { LeafData } from '@leafer/data';
3
3
  import { LeafLayout } from '@leafer/layout';
4
4
 
@@ -59,16 +59,22 @@ declare class Leaf implements ILeaf {
59
59
  __bindLeafer(leafer: ILeaferBase | null): void;
60
60
  set(_data: IObject): void;
61
61
  get(_name?: string): ILeafInputData | IValue;
62
+ setAttr(name: string, value: any): void;
63
+ getAttr(name: string): any;
64
+ getComputedAttr(name: string): any;
62
65
  toJSON(): IObject;
63
66
  toString(): string;
67
+ toSVG(): string;
68
+ __SVG(_data: IObject): void;
69
+ toHTML(): string;
64
70
  __setAttr(_attrName: string, _newValue: IValue): boolean;
65
71
  __getAttr(_attrName: string): IValue;
66
72
  setProxyAttr(_attrName: string, _newValue: IValue): void;
67
73
  getProxyAttr(_attrName: string): IValue;
68
74
  find(_condition: number | string | IFindMethod, _options?: any): ILeaf[];
69
75
  findTag(_tag: string | string[]): ILeaf[];
70
- findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf;
71
- findId(_id: number | string): ILeaf;
76
+ findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf | undefined;
77
+ findId(_id: number | string): ILeaf | undefined;
72
78
  focus(_value?: boolean): void;
73
79
  forceUpdate(attrName?: string): void;
74
80
  updateLayout(): void;
@@ -115,9 +121,9 @@ declare class Leaf implements ILeaf {
115
121
  setTransform(matrix: IMatrixData, resize?: boolean): void;
116
122
  transform(matrix: IMatrixData, resize?: boolean): void;
117
123
  move(x: number | IPointData, y?: number): void;
118
- scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
119
- rotateOf(origin: IPointData, rotation: number): void;
120
- skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
124
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void;
125
+ rotateOf(origin: IPointData | IAlign, rotation: number): void;
126
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void;
121
127
  transformWorld(worldTransform?: IMatrixData, resize?: boolean): void;
122
128
  moveWorld(x: number | IPointData, y?: number): void;
123
129
  scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
@@ -125,6 +131,8 @@ declare class Leaf implements ILeaf {
125
131
  skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
126
132
  scaleResize(scaleX: number, scaleY?: number, _noResize?: boolean): void;
127
133
  __scaleResize(_scaleX: number, _scaleY: number): void;
134
+ resizeWidth(width: number): void;
135
+ resizeHeight(height: number): void;
128
136
  __hitWorld(_point: IRadiusPointData): boolean;
129
137
  __hit(_local: IRadiusPointData): boolean;
130
138
  __hitFill(_inner: IRadiusPointData): boolean;