@leafer/event 1.0.0-beta.8 → 1.0.0-rc.1

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.8",
3
+ "version": "1.0.0-rc.1",
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,9 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/decorator": "1.0.0-beta.8"
25
+ "@leafer/decorator": "1.0.0-rc.1"
23
26
  },
24
27
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.8"
28
+ "@leafer/interface": "1.0.0-rc.1"
26
29
  }
27
30
  }
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
  }
@@ -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
 
@@ -0,0 +1,127 @@
1
+ import { IEvent, IEventTarget, IChildEvent, ILeaf, IPropertyEvent, IImageEvent, ILeaferImage, IObject, IResizeEvent, IScreenSizeData, ITransformEvent, ITransformEventData, IWatchEvent, IWatchEventData, ILayoutEvent, ILayoutBlockData, IAnimateEvent, IRenderEvent, IBounds, IRenderOptions, ILeaferEvent } from '@leafer/interface';
2
+
3
+ declare class Event implements IEvent {
4
+ readonly type: string;
5
+ readonly target: IEventTarget;
6
+ readonly current: IEventTarget;
7
+ readonly bubbles: boolean;
8
+ readonly phase: number;
9
+ isStopDefault: boolean;
10
+ isStop: boolean;
11
+ isStopNow: boolean;
12
+ constructor(type: string, target?: IEventTarget);
13
+ stopDefault(): void;
14
+ stopNow(): void;
15
+ stop(): void;
16
+ }
17
+
18
+ declare class ChildEvent extends Event implements IChildEvent {
19
+ static ADD: string;
20
+ static REMOVE: string;
21
+ readonly parent?: ILeaf;
22
+ readonly child?: ILeaf;
23
+ constructor(type: string, child?: ILeaf, parent?: ILeaf);
24
+ }
25
+
26
+ declare class PropertyEvent extends Event implements IPropertyEvent {
27
+ static CHANGE: string;
28
+ readonly attrName: string;
29
+ readonly oldValue: unknown;
30
+ readonly newValue: unknown;
31
+ constructor(type: string, target: IEventTarget, attrName: string, oldValue: unknown, newValue: unknown);
32
+ }
33
+
34
+ declare class ImageEvent extends Event implements IImageEvent {
35
+ static LOAD: string;
36
+ static LOADED: string;
37
+ static ERROR: string;
38
+ readonly image: ILeaferImage;
39
+ readonly error: string | IObject;
40
+ readonly attrName: string;
41
+ readonly attrValue: IObject;
42
+ constructor(type: string, data: IImageEvent);
43
+ }
44
+
45
+ declare class ResizeEvent extends Event implements IResizeEvent {
46
+ static RESIZE: string;
47
+ readonly width: number;
48
+ readonly height: number;
49
+ readonly pixelRatio: number;
50
+ get bigger(): boolean;
51
+ get smaller(): boolean;
52
+ get samePixelRatio(): boolean;
53
+ readonly old: IScreenSizeData;
54
+ constructor(size: IScreenSizeData | string, oldSize?: IScreenSizeData);
55
+ }
56
+
57
+ declare class TransformEvent extends Event implements ITransformEvent {
58
+ static START: string;
59
+ static CHANGE: string;
60
+ static END: string;
61
+ static BEFORE_START: string;
62
+ static BEFORE_CHANGE: string;
63
+ static BEFORE_END: string;
64
+ readonly x: number;
65
+ readonly y: number;
66
+ readonly scaleX: number;
67
+ readonly scaleY: number;
68
+ readonly rotation: number;
69
+ readonly zooming: boolean;
70
+ readonly moving: boolean;
71
+ readonly rotating: boolean;
72
+ readonly changing: boolean;
73
+ constructor(type: string, params?: ITransformEventData);
74
+ }
75
+
76
+ declare class WatchEvent extends Event implements IWatchEvent {
77
+ static REQUEST: string;
78
+ static DATA: string;
79
+ readonly data: IWatchEventData;
80
+ constructor(type: string, data?: IWatchEventData);
81
+ }
82
+
83
+ declare class LayoutEvent extends Event implements ILayoutEvent {
84
+ static CHECK_UPDATE: string;
85
+ static REQUEST: string;
86
+ static START: string;
87
+ static BEFORE: string;
88
+ static LAYOUT: string;
89
+ static AFTER: string;
90
+ static AGAIN: string;
91
+ static END: string;
92
+ readonly data: ILayoutBlockData[];
93
+ readonly times: number;
94
+ constructor(type: string, data?: ILayoutBlockData[], times?: number);
95
+ }
96
+
97
+ declare class AnimateEvent extends Event implements IAnimateEvent {
98
+ static FRAME: string;
99
+ }
100
+
101
+ declare class RenderEvent extends Event implements IRenderEvent {
102
+ static REQUEST: string;
103
+ static START: string;
104
+ static BEFORE: string;
105
+ static RENDER: string;
106
+ static AFTER: string;
107
+ static AGAIN: string;
108
+ static END: string;
109
+ readonly renderBounds: IBounds;
110
+ readonly renderOptions: IRenderOptions;
111
+ readonly times: number;
112
+ constructor(type: string, times?: number, bounds?: IBounds, options?: IRenderOptions);
113
+ }
114
+
115
+ declare class LeaferEvent extends Event implements ILeaferEvent {
116
+ static START: string;
117
+ static BEFORE_READY: string;
118
+ static READY: string;
119
+ static AFTER_READY: string;
120
+ static VIEW_READY: string;
121
+ static VIEW_COMPLETED: string;
122
+ static STOP: string;
123
+ static RESTART: string;
124
+ static END: string;
125
+ }
126
+
127
+ export { AnimateEvent, ChildEvent, Event, ImageEvent, LayoutEvent, LeaferEvent, PropertyEvent, RenderEvent, ResizeEvent, TransformEvent, WatchEvent };