@leafer/interface 1.0.0-rc.9 → 1.0.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.
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas } from '../../canvas/ILeaferCanvas'
2
- import { IRenderOptions } from '../../renderer/IRenderer'
3
1
  import { IBranch } from '../IBranch'
4
2
  import { ILeafRender } from './ILeafRender'
3
+ import { ILeaferCanvas } from '../../canvas/ILeaferCanvas'
4
+ import { IRenderOptions } from '../../renderer/IRenderer'
5
5
 
6
6
  export type IBranchRenderModule = IBranchRender & ThisType<IBranch>
7
7
 
@@ -15,6 +15,7 @@ export interface ILeafBounds {
15
15
  __updateRenderBounds?(): void
16
16
 
17
17
  __updateAutoLayout?(): void
18
+ __updateFlowLayout?(): void
18
19
  __updateNaturalSize?(): void
19
20
 
20
21
  __updateStrokeSpread?(): number
@@ -4,7 +4,7 @@ import { IValue } from '../../data/IData'
4
4
  export type ILeafDataProxyModule = ILeafDataProxy & ThisType<ILeaf>
5
5
 
6
6
  export interface ILeafDataProxy {
7
- __setAttr?(name: string, newValue: IValue): void
7
+ __setAttr?(name: string, newValue: IValue): boolean
8
8
  __getAttr?(name: string): IValue
9
9
  setProxyAttr?(name: string, newValue: IValue): void
10
10
  getProxyAttr?(name: string): IValue
@@ -8,7 +8,7 @@ export type ILeafEventerModule = ILeafEventer & ThisType<ILeaf>
8
8
 
9
9
  export interface ILeafEventer {
10
10
  on?(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void
11
- off?(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void
11
+ off?(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void
12
12
  on_?(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId
13
13
  off_?(id: IEventListenerId | IEventListenerId[]): void
14
14
  once?(type: string | string[], listener: IEventListener, capture?: boolean): void
@@ -6,7 +6,10 @@ export type ILeafHitModule = ILeafHit & ThisType<ILeaf>
6
6
 
7
7
  export interface ILeafHit {
8
8
  __hitWorld?(point: IRadiusPointData): boolean
9
- __hit?(local: IRadiusPointData): boolean
9
+ __hit?(inner: IRadiusPointData): boolean
10
+ __hitFill?(inner: IRadiusPointData): boolean
11
+ __hitStroke?(inner: IRadiusPointData, strokeWidth: number): boolean
12
+ __hitPixel(inner: IRadiusPointData): boolean
10
13
  __drawHitPath?(canvas: ILeaferCanvas): void
11
14
  __updateHitCanvas?(): void
12
15
  }
@@ -9,7 +9,8 @@ export interface ILeafRender {
9
9
  __draw?(canvas: ILeaferCanvas, options: IRenderOptions): void
10
10
  __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void
11
11
 
12
- __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void
12
+ __clip?(_canvas: ILeaferCanvas, _options: IRenderOptions): void
13
+ __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void
13
14
 
14
15
  __updateWorldOpacity?(): void
15
16
  __updateChange?(): void
@@ -36,7 +36,7 @@ export interface IEventer extends ILeafEventer {
36
36
  __bubbleMap?: IEventListenerMap
37
37
 
38
38
  on(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void
39
- off(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void
39
+ off(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void
40
40
  on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId
41
41
  off_(id: IEventListenerId | IEventListenerId[]): void
42
42
  once(type: string | string[], listener: IEventListener): void
@@ -3,7 +3,7 @@ import { ILeafList } from '../data/IList'
3
3
  import { IEvent } from './IEvent'
4
4
  import { ILeaferImage } from '../image/ILeaferImage'
5
5
  import { ILeaf } from '../display/ILeaf'
6
- import { IPointData } from '../math/IMath'
6
+ import { IPointData, IBoundsData } from '../math/IMath'
7
7
 
8
8
  export interface IUIEvent extends IEvent {
9
9
  x: number
@@ -23,6 +23,7 @@ export interface IUIEvent extends IEvent {
23
23
  path?: ILeafList
24
24
  throughPath?: ILeafList // 穿透path,不受层级影响,从上到下只要碰撞到区域就算,一般点击的时候
25
25
 
26
+ getPage?(): IPointData
26
27
  getInner?(relative?: ILeaf): IPointData
27
28
  getLocal?(relative?: ILeaf): IPointData
28
29
  }
@@ -37,6 +38,7 @@ export interface IPointerEvent extends IUIEvent {
37
38
  tiltX?: number
38
39
  tiltY?: number
39
40
  twist?: number
41
+ isCancel?: boolean
40
42
  }
41
43
  export type PointerType = 'mouse' | 'pen' | 'touch'
42
44
 
@@ -46,10 +48,15 @@ export interface IDragEvent extends IPointerEvent {
46
48
  totalX?: number
47
49
  totalY?: number
48
50
 
51
+ getPageMove?(total?: boolean): IPointData
49
52
  getInnerMove?(relative?: ILeaf): IPointData
50
53
  getLocalMove?(relative?: ILeaf): IPointData
54
+
55
+ getPageTotal?(): IPointData
51
56
  getInnerTotal?(relative?: ILeaf): IPointData
52
57
  getLocalTotal?(relative?: ILeaf): IPointData
58
+
59
+ getPageBounds?(): IBoundsData
53
60
  }
54
61
 
55
62
  export interface IDropEvent extends IPointerEvent {
@@ -0,0 +1,41 @@
1
+ import { IBlob, ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
+ import { ICanvasContext2DSettings } from '../canvas/ICanvas'
3
+ import { ILeaf } from '../display/ILeaf'
4
+ import { ILocationType } from '../layout/ILeafLayout'
5
+ import { IBoundsData } from '../math/IMath'
6
+
7
+ export interface IExportOptions {
8
+ quality?: number
9
+ blob?: boolean
10
+ scale?: number
11
+ smooth?: boolean
12
+ pixelRatio?: number
13
+ slice?: boolean
14
+ trim?: boolean
15
+ fill?: string
16
+ screenshot?: IBoundsData | boolean
17
+ relative?: ILocationType | ILeaf
18
+ json?: IJSONOptions
19
+ contextSettings?: ICanvasContext2DSettings
20
+ onCanvas?: IExportOnCanvasFunction
21
+ }
22
+
23
+ export interface IJSONOptions {
24
+ matrix?: boolean
25
+ }
26
+
27
+ export interface IExportResult {
28
+ data: ILeaferCanvas | IBlob | string | boolean
29
+ width?: number
30
+ height?: number
31
+ renderBounds?: IBoundsData
32
+ trimBounds?: IBoundsData
33
+ }
34
+
35
+ export interface IExportResultFunction {
36
+ (data: IExportResult): void
37
+ }
38
+
39
+ export interface IExportOnCanvasFunction {
40
+ (data: ILeaferCanvas): void
41
+ }
@@ -1,2 +1,2 @@
1
1
  export type IExportImageType = 'jpg' | 'png' | 'webp'
2
- export type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json'
2
+ export type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json'
@@ -1,3 +1,4 @@
1
+ import { IObject } from '../data/IData'
1
2
  import { IPointData } from '../math/IMath'
2
3
 
3
4
  export interface IFunction {
@@ -8,6 +9,14 @@ export interface INumberFunction {
8
9
  (...arg: any): number
9
10
  }
10
11
 
12
+ export interface IStringFunction {
13
+ (...arg: any): string
14
+ }
15
+
16
+ export interface IObjectFunction {
17
+ (...arg: any): IObject
18
+ }
19
+
11
20
  export interface IPointDataFunction {
12
21
  (...arg: any): IPointData
13
22
  }
@@ -11,11 +11,12 @@ export interface IImageManager {
11
11
  recycledList: ILeaferImage[]
12
12
  tasker: ITaskProcessor
13
13
  patternTasker: ITaskProcessor
14
+ patternLocked?: boolean // 锁定pattern不更新, 一般用于创建碰撞位图 UIHit.ts
14
15
  readonly isComplete: boolean
15
16
  get(config: ILeaferImageConfig): ILeaferImage
16
17
  recycle(image: ILeaferImage): void
17
18
  clearRecycled(): void
18
- isPixel(config: ILeaferImageConfig): boolean // png / svg / webp
19
+ hasOpacityPixel(config: ILeaferImageConfig): boolean // png / svg / webp
19
20
  isFormat(format: IExportFileType, config: ILeaferImageConfig): boolean
20
21
  destroy(): void
21
22
  }
@@ -1,6 +1,8 @@
1
+ import { ICanvasPattern } from '../canvas/ICanvas'
1
2
  import { IObject } from '../data/IData'
2
3
  import { InnerId } from '../event/IEventer'
3
4
  import { IExportFileType } from '../file/IFileType'
5
+ import { IMatrixData } from '../math/IMath'
4
6
 
5
7
  export interface ILeaferImageConfig {
6
8
  url: string
@@ -16,6 +18,15 @@ export interface ILeaferImageOnError {
16
18
  (error?: string | IObject, image?: ILeaferImage): any
17
19
  }
18
20
 
21
+ export interface ILeaferImageCacheCanvas {
22
+ data: IObject
23
+ params: IArguments
24
+ }
25
+
26
+ export interface ILeaferImagePatternPaint {
27
+ transform: IMatrixData
28
+ }
29
+
19
30
  export interface ILeaferImage {
20
31
  readonly innerId: InnerId
21
32
  readonly url: string
@@ -25,6 +36,7 @@ export interface ILeaferImage {
25
36
  height: number
26
37
 
27
38
  isSVG: boolean
39
+ hasOpacityPixel: boolean
28
40
 
29
41
  readonly completed: boolean
30
42
  ready: boolean
@@ -37,6 +49,7 @@ export interface ILeaferImage {
37
49
  load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): number
38
50
  unload(index: number, stopEvent?: boolean): void
39
51
  getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown
52
+ getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern
40
53
  destroy(): void
41
54
  }
42
55
 
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { IAppBase } from './app/IApp'
2
- export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode, IEditSize, ICursorType, ICursorTypeMap, IAround } from './display/ILeaf'
2
+ export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator, IZoomType } from './app/ILeafer'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IFlowType, IFlowBoxType, IAlign, IAxisAlign, IFlowAlign, IFlowAxisAlign, IAxis, IGap, IPointGap, IAxisReverse, IBaseLineAlign, IFlowWrap, IAutoSize, IRangeSize, IPercentData, IUnitData, IConstraint, IConstraintType, IHitType, IMaskType, IEraserType, IBlendMode, IEditSize, IImageCursor, ICursorType, IStateStyleType, IDirection, IAround, ILeafAttrDescriptor, ILeafAttrDescriptorFn } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
@@ -14,13 +14,12 @@ export { ILeafBounds, ILeafBoundsModule } from './display/module/ILeafBounds'
14
14
  export { ILeafHit, ILeafHitModule } from './display/module/ILeafHit'
15
15
  export { ILeafRender, ILeafRenderModule } from './display/module/ILeafRender'
16
16
  export { ILeafEventer, ILeafEventerModule } from './display/module/ILeafEventer'
17
- export { ILeafMask, ILeafMaskModule } from './display/module/ILeafMask'
18
17
  export { IBranchRender, IBranchRenderModule } from './display/module/IBranchRender'
19
18
 
20
19
  export { IRenderer, IRendererConfig, IRenderOptions } from './renderer/IRenderer'
21
20
  export { IWatcher, IWatchEventData, IWatcherConfig } from './watcher/IWatcher'
22
21
  export { ILayouter, ILayoutChangedData, ILayoutBlockData, ILayouterConfig, IPartLayoutConfig } from './layouter/ILayouter'
23
- export { ISelector, ISelectorConfig, ISelectorProxy, IFindMethod, ISelectPathResult, ISelectPathOptions, AnswerType } from './selector/ISelector'
22
+ export { ISelector, ISelectorConfig, ISelectorProxy, IFindCondition, IFindMethod, IPickResult, IPickOptions, IPickBottom, IAnswer } from './selector/ISelector'
24
23
 
25
24
  export { ICanvasManager } from './canvas/ICanvasManager'
26
25
  export { IHitCanvasManager } from './canvas/IHitCanvasManager'
@@ -34,22 +33,24 @@ export { IPlatform, IMiniapp, IMiniappSelect, IMiniappSizeView } from './platfor
34
33
  export { IPlugin } from './plugin/IPlugin'
35
34
 
36
35
 
37
- export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
36
+ export { ILeaferCanvas, ILeaferCanvasView, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ICanvasCacheOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
38
37
  export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType, ISkiaNAPICanvas } from './canvas/ISkiaCanvas'
39
38
  export { IPathDrawer, IPathCreator } from './path/IPathDrawer'
40
- export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
39
+ export { IWindingRule, ICanvasContext2D, ICanvasContext2DSettings, ITextMetrics, IPath2D, ICanvasPattern } from './canvas/ICanvas'
41
40
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
42
41
 
43
- export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError } from './image/ILeaferImage'
42
+ export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from './image/ILeaferImage'
44
43
  export { IExportFileType, IExportImageType } from './file/IFileType'
44
+ export { IExportOptions, IJSONOptions, IExportResult, IExportResultFunction, IExportOnCanvasFunction } from './file/IExport'
45
45
 
46
46
  export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
47
47
  export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, IMultiTouchData, IKeepTouchData } from './event/IEvent'
48
48
  export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
49
+ export { ICursorTypeMap, ICursorRotate, ICursorRotateMap } from './interaction/ICursor'
49
50
  export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
50
51
 
51
52
 
52
- export { INumber, IBoolean, IString, IValue, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
53
+ export { INumber, IBoolean, IString, IValue, IFourNumber, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IPointDataMap, IDataTypeHandle } from './data/IData'
53
54
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
54
- export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
55
- export { IFunction, IAttrDecorator } from './function/IFunction'
55
+ export { IPoint, IPointData, IFromToData, IUnitPointData, IScrollPointData, IClientPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, ITwoPointBoundsData, IAutoBounds, IAutoBoxData, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithOptionScaleData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
56
+ export { IFunction, IStringFunction, INumberFunction, IObjectFunction, IPointDataFunction, IAttrDecorator } from './function/IFunction'
@@ -0,0 +1,16 @@
1
+ import { ICursorType } from '../display/ILeaf'
2
+
3
+
4
+ export interface ICursorTypeMap {
5
+ [name: string]: ICursorType | ICursorType[]
6
+ }
7
+
8
+
9
+ export interface ICursorRotate {
10
+ rotation?: number
11
+ data?: string
12
+ }
13
+
14
+ export interface ICursorRotateMap {
15
+ [name: string]: ICursorRotate
16
+ }
@@ -2,8 +2,8 @@ import { INumberFunction, IPointDataFunction } from '../function/IFunction'
2
2
  import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IUIEvent, IKeyEvent } from '../event/IUIEvent'
3
3
  import { ILeaf, ICursorType } from '../display/ILeaf'
4
4
  import { ILeafList } from '../data/IList'
5
- import { IPointData } from '../math/IMath'
6
- import { ISelector, ISelectPathOptions } from '../selector/ISelector'
5
+ import { IClientPointData, IPointData } from '../math/IMath'
6
+ import { ISelector, IPickOptions, IPickBottom } from '../selector/ISelector'
7
7
  import { IBounds } from '../math/IMath'
8
8
  import { IControl } from '../control/IControl'
9
9
  import { IKeepTouchData } from '../event/IEvent'
@@ -18,6 +18,7 @@ export interface IInteraction extends IControl {
18
18
  running: boolean
19
19
  readonly dragging: boolean
20
20
  readonly isDragEmpty: boolean
21
+ readonly isHoldRightKey: boolean
21
22
  readonly moveMode: boolean
22
23
 
23
24
  config: IInteractionConfig
@@ -25,11 +26,14 @@ export interface IInteraction extends IControl {
25
26
  cursor: ICursorType | ICursorType[]
26
27
  readonly hitRadius: number
27
28
 
29
+ bottomList?: IPickBottom[] // 底部可拾取的虚拟元素
30
+
28
31
  shrinkCanvasBounds: IBounds
29
32
 
30
33
  downData: IPointerEvent
31
34
  hoverData: IPointerEvent
32
35
  downTime: number
36
+ focusData: ILeaf
33
37
 
34
38
  receive(event: any): void
35
39
 
@@ -48,12 +52,25 @@ export interface IInteraction extends IControl {
48
52
  keyDown(data: IKeyEvent): void
49
53
  keyUp(data: IKeyEvent): void
50
54
 
51
- findPath(data: IPointerEvent, options?: ISelectPathOptions): ILeafList
55
+ findPath(data: IPointerEvent, options?: IPickOptions): ILeafList
56
+ isRootPath(data: IPointerEvent): boolean
57
+ isTreePath(data: IPointerEvent): boolean
58
+ canMove(data: IPointerEvent): boolean
59
+
52
60
  isDrag(leaf: ILeaf): boolean
61
+ isPress(leaf: ILeaf): boolean
62
+ isHover(leaf: ILeaf): boolean
63
+ isFocus(leaf: ILeaf): boolean
64
+
65
+ cancelHover(): void
53
66
 
54
- updateDownData(data?: IPointerEvent): void
67
+ updateDownData(data?: IPointerEvent, options?: IPickOptions, merge?: boolean): void
55
68
  updateHoverData(data: IPointerEvent): void
69
+
56
70
  updateCursor(hoverData?: IPointerEvent): void
71
+ setCursor(cursor: ICursorType | ICursorType[]): void
72
+
73
+ getLocal(clientPoint: IClientPointData, updateClient?: boolean): IPointData
57
74
 
58
75
  emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
59
76
  }
@@ -65,26 +82,34 @@ export interface IInteractionCanvas extends ILeaferCanvas {
65
82
  export interface IInteractionConfig {
66
83
  wheel?: IWheelConfig
67
84
  pointer?: IPointerConfig
68
- cursor?: ICursorConfig
69
85
  zoom?: IZoomConfig
70
86
  move?: IMoveConfig
71
87
  eventer?: IObject
88
+ cursor?: boolean
89
+ keyEvent?: boolean
72
90
  }
73
91
 
74
92
  export interface IZoomConfig {
93
+ disabled?: boolean
75
94
  min?: number
76
95
  max?: number
77
96
  }
78
97
 
79
98
  export interface IMoveConfig {
99
+ disabled?: boolean
80
100
  holdSpaceKey?: boolean
101
+ holdMiddleKey?: boolean
102
+ holdRightKey?: boolean
103
+ scroll?: boolean | 'limit'
81
104
  drag?: boolean
105
+ dragAnimate?: boolean
82
106
  dragEmpty?: boolean
83
107
  dragOut?: boolean
84
108
  autoDistance?: number
85
109
  }
86
110
 
87
111
  export interface IWheelConfig {
112
+ disabled?: boolean
88
113
  zoomMode?: boolean | 'mouse'
89
114
  zoomSpeed?: number // 取值范围 0 ~ 1, 默认0.5
90
115
  moveSpeed?: number
@@ -102,11 +127,13 @@ export interface IPointerConfig {
102
127
  tapTime?: number
103
128
  longPressTime?: number
104
129
  transformTime?: number
130
+ hover?: boolean
105
131
  dragHover?: boolean
106
132
  dragDistance?: number
107
133
  swipeDistance?: number
108
134
  ignoreMove?: boolean // 性能优化字段, 控制move事件触发次数
109
135
  preventDefault?: boolean
136
+ preventDefaultMenu?: boolean
110
137
  }
111
138
 
112
139
  export interface ICursorConfig {
@@ -1,8 +1,8 @@
1
1
  import { IBoundsData, IMatrixData, ILayoutBoundsData, IPointData } from '../math/IMath'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
 
4
- export type ILocationType = 'world' | 'local' | 'inner'
5
- export type IBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
4
+ export type ILocationType = 'world' | 'page' | 'local' | 'inner'
5
+ export type IBoundsType = 'content' | 'box' | 'stroke' | 'render'
6
6
 
7
7
  export interface ILeafLayout {
8
8
 
@@ -12,19 +12,24 @@ export interface ILeafLayout {
12
12
 
13
13
  // inner
14
14
 
15
+ contentBounds: IBoundsData // | content |
15
16
  boxBounds: IBoundsData // | content + padding |
16
17
  strokeBounds: IBoundsData // | boxBounds + border |
17
18
  renderBounds: IBoundsData // | strokeBounds + shadow |
18
19
 
19
- // auto layout
20
- marginBounds: IBoundsData // | strokeBounds + margin |
21
- contentBounds: IBoundsData // | content |
22
-
23
20
  // local
24
21
 
25
- //localBoxBounds: IBoundsData = leaf.__local
26
- localStrokeBounds?: IBoundsData
27
- localRenderBounds?: IBoundsData
22
+ localContentBounds: IBoundsData
23
+ // localBoxBounds: IBoundsData // use leaf.__localBoxBounds
24
+ localStrokeBounds: IBoundsData
25
+ localRenderBounds: IBoundsData
26
+
27
+ // world
28
+
29
+ worldContentBounds: IBoundsData
30
+ worldBoxBounds: IBoundsData
31
+ worldStrokeBounds: IBoundsData
32
+ // worldRenderBounds: IBoundsData // use leaf.__world
28
33
 
29
34
  // state
30
35
  resized: boolean
@@ -58,8 +63,8 @@ export interface ILeafLayout {
58
63
  affectChildrenSort?: boolean
59
64
 
60
65
  strokeSpread: number
61
- renderSpread: number
62
- strokeBoxSpread: number
66
+ strokeBoxSpread: number // 用于生成strokeBounds
67
+ renderSpread: number // -1 表示需监视变化,不影响实际renderBounds,目前用在Box上
63
68
  renderShapeSpread: number
64
69
 
65
70
  // temp local
@@ -69,6 +74,12 @@ export interface ILeafLayout {
69
74
  d: number
70
75
  e: number
71
76
  f: number
77
+ x: number
78
+ y: number
79
+ width: number
80
+ height: number
81
+
82
+ createLocal(): void
72
83
 
73
84
  update(): void
74
85
 
@@ -78,8 +89,10 @@ export interface ILeafLayout {
78
89
  getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[]
79
90
 
80
91
  // 独立 / 引用 boxBounds
92
+ shrinkContent(): void
81
93
  spreadStroke(): void
82
94
  spreadRender(): void
95
+ shrinkContentCancel(): void
83
96
  spreadStrokeCancel(): void
84
97
  spreadRenderCancel(): void
85
98
 
package/src/math/IMath.ts CHANGED
@@ -1,15 +1,39 @@
1
- import { IObject } from '../data/IData'
1
+ import { IFourNumber, IObject } from '../data/IData'
2
2
 
3
3
  export interface IPointData {
4
4
  x: number
5
5
  y: number
6
6
  }
7
7
 
8
+ export interface IUnitPointData {
9
+ type?: 'percent' | 'px'
10
+ x: number
11
+ y: number
12
+ }
13
+
14
+ export interface IFromToData {
15
+ from: IPointData
16
+ to: IPointData
17
+ }
18
+
19
+ export interface IScrollPointData {
20
+ scrollX: number
21
+ scrollY: number
22
+ }
23
+
24
+ export interface IClientPointData {
25
+ clientX: number
26
+ clientY: number
27
+ }
28
+
8
29
  export interface IPoint extends IPointData {
9
30
  set(x?: number | IPointData, y?: number): IPoint
10
31
  get(): IPointData
11
32
  clone(): IPoint
12
33
 
34
+ move(x: number, y: number): IPoint
35
+ scale(scaleX: number, scaleY?: number): IPoint
36
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint
13
37
  rotate(rotation: number, origin?: IPointData): IPoint
14
38
  rotateOf(origin: IPointData, rotation: number): IPoint
15
39
  getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number
@@ -19,7 +43,7 @@ export interface IPoint extends IPointData {
19
43
 
20
44
  getCenter(to: IPointData): IPoint
21
45
  getDistance(to: IPointData): number
22
- getDistancePoint(to: IPointData, distance: number): IPoint
46
+ getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint
23
47
 
24
48
  getAngle(to: IPointData): number
25
49
  getAtan2(to: IPointData): number
@@ -60,14 +84,18 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
60
84
  get(): IBoundsData
61
85
  clone(): IBounds
62
86
 
87
+ move(x: number, y: number): IBounds
63
88
  scale(scaleX: number, scaleY?: number): IBounds
64
89
  scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds
65
90
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
66
- getFitMatrix(put: IBoundsData): IMatrix
91
+ toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds
92
+ getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix
67
93
 
68
- spread(spreadX: number, spreadY?: number): IBounds
94
+ spread(fourNumber: IFourNumber): IBounds
95
+ shrink(fourNumber: IFourNumber): IBounds
69
96
  ceil(): IBounds
70
97
  unsign(): IBounds
98
+ float(maxLength?: number): IBounds
71
99
 
72
100
  add(bounds: IBoundsData): IBounds
73
101
  addList(boundsList: IBoundsData[]): IBounds
@@ -75,7 +103,9 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
75
103
  addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
76
104
  setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
77
105
 
106
+ setPoint(point: IPointData): IBounds
78
107
  setPoints(points: IPointData[]): IBounds
108
+ addPoint(point: IPointData): IBounds
79
109
  getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
80
110
 
81
111
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
@@ -98,13 +128,15 @@ export interface ITwoPointBoundsData {
98
128
  maxY: number
99
129
  }
100
130
 
101
-
102
- export interface IAutoBoundsData {
131
+ export interface IAutoBoxData {
103
132
  top?: number
104
133
  right?: number
105
134
  bottom?: number
106
135
  left?: number
136
+ }
107
137
 
138
+
139
+ export interface IAutoBoundsData extends IAutoBoxData {
108
140
  width?: number
109
141
  height?: number
110
142
  }
@@ -155,8 +187,10 @@ export type ILayoutAttr =
155
187
 
156
188
  export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
157
189
  }
158
- export interface IMatrix extends IMatrixData {
190
+ export interface IMatrix extends IMatrixWithScaleData {
191
+
159
192
  set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
193
+ setWith(dataWithScale: IMatrixWithScaleData): IMatrix // set scaleX scaleY
160
194
  get(): IMatrixData
161
195
  clone(): IMatrix
162
196
 
@@ -164,6 +198,7 @@ export interface IMatrix extends IMatrixData {
164
198
  translateInner(x: number, y: number): IMatrix
165
199
 
166
200
  scale(x: number, y?: number): IMatrix
201
+ scaleWith(x: number, y?: number): IMatrix // change scaleX scaleY
167
202
  scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix
168
203
  scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix
169
204
 
@@ -181,6 +216,7 @@ export interface IMatrix extends IMatrixData {
181
216
  divide(child: IMatrixData): IMatrix
182
217
  divideParent(parent: IMatrixData): IMatrix
183
218
  invert(): IMatrix
219
+ invertWith(): IMatrix // change scaleX scaleY
184
220
 
185
221
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
186
222
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
@@ -188,6 +224,8 @@ export interface IMatrix extends IMatrixData {
188
224
  setLayout(data: ILayoutData, origin?: IPointData): IMatrix
189
225
  getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
190
226
 
227
+ withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData
228
+
191
229
  reset(): void
192
230
  }
193
231
 
@@ -195,4 +233,11 @@ export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
195
233
 
196
234
  export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
197
235
 
236
+ export interface IMatrixWithOptionScaleData extends IMatrixData {
237
+ scaleX?: number
238
+ scaleY?: number
239
+ }
240
+
241
+ export interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData { }
242
+
198
243
  export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }