@leafer/event 1.0.0-beta.9 → 1.0.0-rc.10

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/event",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer/event",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,9 +22,10 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/decorator": "1.0.0-beta.9"
25
+ "@leafer/decorator": "1.0.0-rc.10",
26
+ "@leafer/platform": "1.0.0-rc.10"
23
27
  },
24
28
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.9"
29
+ "@leafer/interface": "1.0.0-rc.10"
26
30
  }
27
31
  }
package/src/Event.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { IEvent, IEventTarget } from '@leafer/interface'
1
+ import { IEvent, IEventTarget, IObject } from '@leafer/interface'
2
+ import { Platform } from '@leafer/platform'
2
3
 
3
4
 
4
5
  export class Event implements IEvent {
5
6
 
7
+ readonly origin: IObject
8
+
6
9
  readonly type: string
7
10
  readonly target: IEventTarget
8
11
  readonly current: IEventTarget
@@ -21,14 +24,17 @@ export class Event implements IEvent {
21
24
 
22
25
  public stopDefault(): void {
23
26
  this.isStopDefault = true
27
+ if (this.origin) Platform.event.stopDefault(this.origin)
24
28
  }
25
29
 
26
30
  public stopNow(): void {
27
31
  this.isStopNow = true
28
32
  this.isStop = true
33
+ if (this.origin) Platform.event.stopNow(this.origin)
29
34
  }
30
35
 
31
36
  public stop(): void {
32
37
  this.isStop = true
38
+ if (this.origin) Platform.event.stop(this.origin)
33
39
  }
34
40
  }
package/src/ImageEvent.ts CHANGED
@@ -1,24 +1,22 @@
1
- import { IImageEvent, IObject, IEventTarget, ILeaferImage } from '@leafer/interface'
1
+ import { IImageEvent, IObject, ILeaferImage } from '@leafer/interface'
2
2
 
3
3
  import { Event } from './Event'
4
4
 
5
5
  export class ImageEvent extends Event implements IImageEvent {
6
6
 
7
+ static LOAD = 'image.load'
7
8
  static LOADED = 'image.loaded'
8
9
  static ERROR = 'image.error'
9
10
 
10
11
  readonly image: ILeaferImage
11
12
  readonly error: string | IObject
12
13
 
13
- readonly attrName?: string
14
- readonly attrValue?: IObject
14
+ readonly attrName: string
15
+ readonly attrValue: IObject
15
16
 
16
- constructor(type: string, target: IEventTarget, image: ILeaferImage, attrName?: string, attrValue?: IObject, error?: string | IObject) {
17
- super(type, target)
18
- this.image = image
19
- this.attrName = attrName
20
- this.attrValue = attrValue
21
- if (error) this.error = error
17
+ constructor(type: string, data: IImageEvent) {
18
+ super(type)
19
+ Object.assign(this, data)
22
20
  }
23
21
 
24
22
  }
@@ -12,7 +12,7 @@ export class LayoutEvent extends Event implements ILayoutEvent {
12
12
  static START = 'layout.start'
13
13
 
14
14
  static BEFORE = 'layout.before'
15
- static LAYOUT = 'layout.layout'
15
+ static LAYOUT = 'layout'
16
16
  static AFTER = 'layout.after'
17
17
 
18
18
  static AGAIN = 'layout.again'
@@ -13,6 +13,8 @@ export class LeaferEvent extends Event implements ILeaferEvent {
13
13
 
14
14
  static VIEW_READY = 'leafer.view_ready'
15
15
 
16
+ static VIEW_COMPLETED = 'leafer.view_completed'
17
+
16
18
  static STOP = 'leafer.stop'
17
19
  static RESTART = 'leafer.restart'
18
20
 
@@ -6,6 +6,7 @@ import { Event } from './Event'
6
6
  export class PropertyEvent extends Event implements IPropertyEvent {
7
7
 
8
8
  static CHANGE = 'property.change'
9
+ static LEAFER_CHANGE = 'property.leafer_change'
9
10
 
10
11
  readonly attrName: string
11
12
  readonly oldValue: unknown
@@ -17,6 +17,8 @@ export class RenderEvent extends Event implements IRenderEvent {
17
17
 
18
18
  static END = 'render.end'
19
19
 
20
+ static NEXT = 'render.next'
21
+
20
22
  readonly renderBounds: IBounds
21
23
  readonly renderOptions: IRenderOptions
22
24
  readonly times: number
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@ export { ChildEvent } from './ChildEvent'
2
2
  export { PropertyEvent } from './PropertyEvent'
3
3
  export { ImageEvent } from './ImageEvent'
4
4
  export { ResizeEvent } from './ResizeEvent'
5
- export { TransformEvent } from './TransformEvent'
6
5
  export { WatchEvent } from './WatchEvent'
7
6
  export { LayoutEvent } from './LayoutEvent'
8
7
  export { AnimateEvent } from './AnimateEvent'
@@ -0,0 +1,111 @@
1
+ import { IEvent, IObject, IEventTarget, IChildEvent, ILeaf, IPropertyEvent, IImageEvent, ILeaferImage, IResizeEvent, IScreenSizeData, IWatchEvent, IWatchEventData, ILayoutEvent, ILayoutBlockData, IAnimateEvent, IRenderEvent, IBounds, IRenderOptions, ILeaferEvent } from '@leafer/interface';
2
+
3
+ declare class Event implements IEvent {
4
+ readonly origin: IObject;
5
+ readonly type: string;
6
+ readonly target: IEventTarget;
7
+ readonly current: IEventTarget;
8
+ readonly bubbles: boolean;
9
+ readonly phase: number;
10
+ isStopDefault: boolean;
11
+ isStop: boolean;
12
+ isStopNow: boolean;
13
+ constructor(type: string, target?: IEventTarget);
14
+ stopDefault(): void;
15
+ stopNow(): void;
16
+ stop(): void;
17
+ }
18
+
19
+ declare class ChildEvent extends Event implements IChildEvent {
20
+ static ADD: string;
21
+ static REMOVE: string;
22
+ readonly parent?: ILeaf;
23
+ readonly child?: ILeaf;
24
+ constructor(type: string, child?: ILeaf, parent?: ILeaf);
25
+ }
26
+
27
+ declare class PropertyEvent extends Event implements IPropertyEvent {
28
+ static CHANGE: string;
29
+ static LEAFER_CHANGE: string;
30
+ readonly attrName: string;
31
+ readonly oldValue: unknown;
32
+ readonly newValue: unknown;
33
+ constructor(type: string, target: IEventTarget, attrName: string, oldValue: unknown, newValue: unknown);
34
+ }
35
+
36
+ declare class ImageEvent extends Event implements IImageEvent {
37
+ static LOAD: string;
38
+ static LOADED: string;
39
+ static ERROR: string;
40
+ readonly image: ILeaferImage;
41
+ readonly error: string | IObject;
42
+ readonly attrName: string;
43
+ readonly attrValue: IObject;
44
+ constructor(type: string, data: IImageEvent);
45
+ }
46
+
47
+ declare class ResizeEvent extends Event implements IResizeEvent {
48
+ static RESIZE: string;
49
+ readonly width: number;
50
+ readonly height: number;
51
+ readonly pixelRatio: number;
52
+ get bigger(): boolean;
53
+ get smaller(): boolean;
54
+ get samePixelRatio(): boolean;
55
+ readonly old: IScreenSizeData;
56
+ constructor(size: IScreenSizeData | string, oldSize?: IScreenSizeData);
57
+ }
58
+
59
+ declare class WatchEvent extends Event implements IWatchEvent {
60
+ static REQUEST: string;
61
+ static DATA: string;
62
+ readonly data: IWatchEventData;
63
+ constructor(type: string, data?: IWatchEventData);
64
+ }
65
+
66
+ declare class LayoutEvent extends Event implements ILayoutEvent {
67
+ static CHECK_UPDATE: string;
68
+ static REQUEST: string;
69
+ static START: string;
70
+ static BEFORE: string;
71
+ static LAYOUT: string;
72
+ static AFTER: string;
73
+ static AGAIN: string;
74
+ static END: string;
75
+ readonly data: ILayoutBlockData[];
76
+ readonly times: number;
77
+ constructor(type: string, data?: ILayoutBlockData[], times?: number);
78
+ }
79
+
80
+ declare class AnimateEvent extends Event implements IAnimateEvent {
81
+ static FRAME: string;
82
+ }
83
+
84
+ declare class RenderEvent extends Event implements IRenderEvent {
85
+ static REQUEST: string;
86
+ static START: string;
87
+ static BEFORE: string;
88
+ static RENDER: string;
89
+ static AFTER: string;
90
+ static AGAIN: string;
91
+ static END: string;
92
+ static NEXT: string;
93
+ readonly renderBounds: IBounds;
94
+ readonly renderOptions: IRenderOptions;
95
+ readonly times: number;
96
+ constructor(type: string, times?: number, bounds?: IBounds, options?: IRenderOptions);
97
+ }
98
+
99
+ declare class LeaferEvent extends Event implements ILeaferEvent {
100
+ static START: string;
101
+ static BEFORE_READY: string;
102
+ static READY: string;
103
+ static AFTER_READY: string;
104
+ static VIEW_READY: string;
105
+ static VIEW_COMPLETED: string;
106
+ static STOP: string;
107
+ static RESTART: string;
108
+ static END: string;
109
+ }
110
+
111
+ export { AnimateEvent, ChildEvent, Event, ImageEvent, LayoutEvent, LeaferEvent, PropertyEvent, RenderEvent, ResizeEvent, WatchEvent };
@@ -1,32 +0,0 @@
1
- import { ITransformEvent, ITransformEventData } from '@leafer/interface'
2
-
3
- import { Event } from './Event'
4
-
5
-
6
- export class TransformEvent extends Event implements ITransformEvent {
7
-
8
- static START = 'transform.start'
9
- static CHANGE = 'transform.change'
10
- static END = 'transform.end'
11
-
12
- static BEFORE_START = 'transform.before_start'
13
- static BEFORE_CHANGE = 'transform.before_change'
14
- static BEFORE_END = 'transform.before_end'
15
-
16
- readonly x: number
17
- readonly y: number
18
- readonly scaleX: number
19
- readonly scaleY: number
20
- readonly rotation: number
21
-
22
- readonly zooming: boolean
23
- readonly moving: boolean
24
- readonly rotating: boolean
25
- readonly changing: boolean
26
-
27
- constructor(type: string, params?: ITransformEventData) {
28
- super(type)
29
- if (params) Object.assign(this, params)
30
- }
31
-
32
- }