@leafer/display 1.0.0-rc.25 → 1.0.0-rc.26

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.26",
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.26",
26
+ "@leafer/data": "1.0.0-rc.26",
27
+ "@leafer/layout": "1.0.0-rc.26",
28
+ "@leafer/display-module": "1.0.0-rc.26",
29
+ "@leafer/event": "1.0.0-rc.26",
30
+ "@leafer/decorator": "1.0.0-rc.26",
31
+ "@leafer/helper": "1.0.0-rc.26",
32
+ "@leafer/platform": "1.0.0-rc.26"
33
33
  },
34
34
  "devDependencies": {
35
- "@leafer/interface": "1.0.0-rc.25"
35
+ "@leafer/interface": "1.0.0-rc.26"
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)
@@ -181,6 +181,12 @@ export class Leaf implements ILeaf {
181
181
  return JSON.stringify(this.toJSON())
182
182
  }
183
183
 
184
+ public toSVG(): string { return undefined }
185
+
186
+ public __SVG(_data: IObject): void { }
187
+
188
+ public toHTML(): string { return undefined }
189
+
184
190
  // LeafDataProxy rewrite
185
191
 
186
192
  public __setAttr(_attrName: string, _newValue: IValue): boolean { return true }
@@ -200,9 +206,9 @@ export class Leaf implements ILeaf {
200
206
 
201
207
  public findTag(_tag: string | string[]): ILeaf[] { return undefined }
202
208
 
203
- public findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf { return undefined }
209
+ public findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf | undefined { return undefined }
204
210
 
205
- public findId(_id: number | string): ILeaf { return undefined }
211
+ public findId(_id: number | string): ILeaf | undefined { return undefined }
206
212
 
207
213
  // ---
208
214
 
@@ -435,19 +441,18 @@ export class Leaf implements ILeaf {
435
441
  moveLocal(this, x, y)
436
442
  }
437
443
 
438
- public scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void {
439
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize)
444
+ public scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void {
445
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize)
440
446
  }
441
447
 
442
- public rotateOf(origin: IPointData, rotation: number): void {
443
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation)
448
+ public rotateOf(origin: IPointData | IAlign, rotation: number): void {
449
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation)
444
450
  }
445
451
 
446
- public skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void {
447
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize)
452
+ public skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void {
453
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize)
448
454
  }
449
455
 
450
-
451
456
  public transformWorld(worldTransform?: IMatrixData, resize?: boolean): void {
452
457
  transformWorld(this, worldTransform, resize)
453
458
  }
@@ -478,6 +483,18 @@ export class Leaf implements ILeaf {
478
483
 
479
484
  public __scaleResize(_scaleX: number, _scaleY: number): void { }
480
485
 
486
+
487
+ public resizeWidth(width: number): void {
488
+ const scale = width / this.__localBoxBounds.width
489
+ this.scaleResize(scale, this.__.lockRatio ? scale : 1)
490
+ }
491
+
492
+ public resizeHeight(height: number): void {
493
+ const scale = height / this.__localBoxBounds.height
494
+ this.scaleResize(this.__.lockRatio ? scale : 1, scale)
495
+ }
496
+
497
+
481
498
  // @leafer-ui/hit LeafHit rewrite
482
499
 
483
500
  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
 
@@ -61,14 +61,17 @@ declare class Leaf implements ILeaf {
61
61
  get(_name?: string): ILeafInputData | IValue;
62
62
  toJSON(): IObject;
63
63
  toString(): string;
64
+ toSVG(): string;
65
+ __SVG(_data: IObject): void;
66
+ toHTML(): string;
64
67
  __setAttr(_attrName: string, _newValue: IValue): boolean;
65
68
  __getAttr(_attrName: string): IValue;
66
69
  setProxyAttr(_attrName: string, _newValue: IValue): void;
67
70
  getProxyAttr(_attrName: string): IValue;
68
71
  find(_condition: number | string | IFindMethod, _options?: any): ILeaf[];
69
72
  findTag(_tag: string | string[]): ILeaf[];
70
- findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf;
71
- findId(_id: number | string): ILeaf;
73
+ findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf | undefined;
74
+ findId(_id: number | string): ILeaf | undefined;
72
75
  focus(_value?: boolean): void;
73
76
  forceUpdate(attrName?: string): void;
74
77
  updateLayout(): void;
@@ -115,9 +118,9 @@ declare class Leaf implements ILeaf {
115
118
  setTransform(matrix: IMatrixData, resize?: boolean): void;
116
119
  transform(matrix: IMatrixData, resize?: boolean): void;
117
120
  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;
121
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void;
122
+ rotateOf(origin: IPointData | IAlign, rotation: number): void;
123
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void;
121
124
  transformWorld(worldTransform?: IMatrixData, resize?: boolean): void;
122
125
  moveWorld(x: number | IPointData, y?: number): void;
123
126
  scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
@@ -125,6 +128,8 @@ declare class Leaf implements ILeaf {
125
128
  skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
126
129
  scaleResize(scaleX: number, scaleY?: number, _noResize?: boolean): void;
127
130
  __scaleResize(_scaleX: number, _scaleY: number): void;
131
+ resizeWidth(width: number): void;
132
+ resizeHeight(height: number): void;
128
133
  __hitWorld(_point: IRadiusPointData): boolean;
129
134
  __hit(_local: IRadiusPointData): boolean;
130
135
  __hitFill(_inner: IRadiusPointData): boolean;