@netless/forge-slide 0.1.1-alpha.7 → 0.1.1-alpha.8
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/dist/SiderBarView.d.ts +4 -0
- package/dist/SiderBarView.d.ts.map +1 -1
- package/dist/Slide.d.ts +1 -0
- package/dist/Slide.d.ts.map +1 -1
- package/dist/SlideApplication.d.ts +3 -0
- package/dist/SlideApplication.d.ts.map +1 -1
- package/dist/index.esm.js +175 -105
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +175 -105
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/SiderBarView.ts +24 -3
- package/src/Slide.ts +1 -0
- package/src/SlideApplication.ts +141 -106
package/package.json
CHANGED
package/src/SiderBarView.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface SideBarViewEvents {
|
|
|
7
7
|
|
|
8
8
|
export class SideBarView extends EventEmitter<SideBarViewEvents> {
|
|
9
9
|
public readonly root: HTMLDivElement = document.createElement("div");
|
|
10
|
+
private isShow: boolean = false;
|
|
10
11
|
private itemList: HTMLDivElement[] = [];
|
|
11
12
|
|
|
12
13
|
public constructor() {
|
|
@@ -21,13 +22,14 @@ export class SideBarView extends EventEmitter<SideBarViewEvents> {
|
|
|
21
22
|
this.root.style.zIndex = "5";
|
|
22
23
|
this.root.style.transition = "left 0.3s ease-in-out";
|
|
23
24
|
this.root.style.overflow = "auto";
|
|
24
|
-
this.root.style.border = "1px solid #ccc";
|
|
25
|
-
this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
|
|
26
25
|
this.root.style.display = "flex";
|
|
27
26
|
this.root.style.flexDirection = "column";
|
|
28
27
|
this.root.style.justifyContent = "flex-start";
|
|
29
28
|
this.root.style.alignItems = "center";
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
+
get isShowSideBar(): boolean {
|
|
32
|
+
return this.isShow;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
private onMouseOver = (itemContainer: HTMLDivElement) => {
|
|
@@ -50,7 +52,6 @@ export class SideBarView extends EventEmitter<SideBarViewEvents> {
|
|
|
50
52
|
itemContainer.style.display = "flex";
|
|
51
53
|
itemContainer.style.justifyContent = "center";
|
|
52
54
|
itemContainer.style.alignItems = "flex-start";
|
|
53
|
-
itemContainer.style.border = "7px solid transparent";
|
|
54
55
|
itemContainer.style.position = "relative";
|
|
55
56
|
itemContainer.style.borderRadius = "4px"
|
|
56
57
|
itemContainer.style.transition = "border-color .3s";
|
|
@@ -81,6 +82,26 @@ export class SideBarView extends EventEmitter<SideBarViewEvents> {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
public hidden() {
|
|
86
|
+
if (!this.root) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.root.style.left = "-240px";
|
|
90
|
+
this.root.style.border = "none";
|
|
91
|
+
this.root.style.boxShadow = "none";
|
|
92
|
+
this.isShow = false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public show() {
|
|
96
|
+
if (!this.root) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.root.style.left = "0";
|
|
100
|
+
this.root.style.border = "1px solid #ccc";
|
|
101
|
+
this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
|
|
102
|
+
this.isShow = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
84
105
|
public dispose() {
|
|
85
106
|
this.itemList.forEach(item => {
|
|
86
107
|
item.removeEventListener("mouseover", () => this.onMouseOver(item))
|
package/src/Slide.ts
CHANGED
|
@@ -43,6 +43,7 @@ export class SlideForge extends EventEmitter<SlideEvents> implements Application
|
|
|
43
43
|
public readonly permissions!: ForgeSlidePermissions;
|
|
44
44
|
public readonly footView!: HTMLDivElement;
|
|
45
45
|
public readonly sideBarView!: HTMLDivElement;
|
|
46
|
+
public readonly whiteboardView!: HTMLDivElement;
|
|
46
47
|
/**
|
|
47
48
|
* 当前页面索引, 从 0 开始
|
|
48
49
|
*/
|
package/src/SlideApplication.ts
CHANGED
|
@@ -119,10 +119,10 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
119
119
|
if (!this.permissions.hasPermission(ForgeSlidePermissionFlag.changePage)) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
if (this.sideBar.
|
|
123
|
-
this.sideBar.
|
|
122
|
+
if (this.sideBar.isShowSideBar) {
|
|
123
|
+
this.sideBar.hidden();
|
|
124
124
|
} else {
|
|
125
|
-
this.sideBar.
|
|
125
|
+
this.sideBar.show();
|
|
126
126
|
}
|
|
127
127
|
})
|
|
128
128
|
|
|
@@ -131,102 +131,91 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
131
131
|
this.emitter.on("renderStart", pageIndex => {
|
|
132
132
|
this.footer.prevPageState(pageIndex !== 0);
|
|
133
133
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
Object.defineProperty(this.emitter, "view", {
|
|
137
|
-
get(): any {
|
|
138
|
-
return that.rootView;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(this.emitter, "permissions", {
|
|
142
|
-
get(): any {
|
|
143
|
-
return that.permissions;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
Object.defineProperty(this.emitter, "footView", {
|
|
147
|
-
get(): any {
|
|
148
|
-
return that.footer.root;
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
Object.defineProperty(this.emitter, "sidebarView", {
|
|
152
|
-
get(): any {
|
|
153
|
-
return that.sideBar.root;
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
Object.defineProperty(this.emitter, "pageIndex", {
|
|
157
|
-
get(): any {
|
|
158
|
-
return that.currentSlideIndex;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(this.emitter, "pageCount", {
|
|
162
|
-
get(): any {
|
|
163
|
-
return that.slideCount;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
Object.defineProperty(this.emitter, "goto", {
|
|
167
|
-
writable: false,
|
|
168
|
-
enumerable: false,
|
|
169
|
-
value: (pageIndex: number) => {
|
|
170
|
-
this.sideBar.emit("pageChange", pageIndex);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
Object.defineProperty(this.emitter, "nextStep", {
|
|
174
|
-
writable: false,
|
|
175
|
-
enumerable: false,
|
|
176
|
-
value: () => {
|
|
177
|
-
this.footer.emit("nextStep");
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
Object.defineProperty(this.emitter, "prevStep", {
|
|
181
|
-
writable: false,
|
|
182
|
-
enumerable: false,
|
|
183
|
-
value: () => {
|
|
184
|
-
this.footer.emit("prevStep");
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
Object.defineProperty(this.emitter, "nextPage", {
|
|
188
|
-
writable: false,
|
|
189
|
-
enumerable: false,
|
|
190
|
-
value: () => {
|
|
191
|
-
this.footer.emit("nextPage");
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
Object.defineProperty(this.emitter, "prevPage", {
|
|
195
|
-
writable: false,
|
|
196
|
-
enumerable: false,
|
|
197
|
-
value: () => {
|
|
198
|
-
this.footer.emit("prevPage");
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
Object.defineProperty(this.emitter, "sideBarToggle", {
|
|
202
|
-
writable: false,
|
|
203
|
-
enumerable: false,
|
|
204
|
-
value: () => {
|
|
205
|
-
this.footer.emit("sideBarToggle");
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
Object.defineProperty(this.emitter, "imgContent", {
|
|
209
|
-
writable: false,
|
|
210
|
-
enumerable: false,
|
|
211
|
-
value: (pageIndex: number) => {
|
|
212
|
-
return this.getImageContent(pageIndex);
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
Object.defineProperty(this.emitter, "imgUrl", {
|
|
217
|
-
writable: false,
|
|
218
|
-
enumerable: false,
|
|
219
|
-
value: (pageIndex: number) => {
|
|
220
|
-
return this.getImageUrl(pageIndex);
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
Object.defineProperty(this.emitter, "imgSize", {
|
|
225
|
-
writable: false,
|
|
134
|
+
const propertyConfig = {
|
|
135
|
+
configurable: false,
|
|
226
136
|
enumerable: false,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
137
|
+
writable: false
|
|
138
|
+
}
|
|
139
|
+
const that = this;
|
|
140
|
+
Object.defineProperties(this.emitter, {
|
|
141
|
+
view: {
|
|
142
|
+
get(): HTMLDivElement { return that.rootView }
|
|
143
|
+
},
|
|
144
|
+
permissions: {
|
|
145
|
+
get(): ForgeSlidePermissions { return that.permissions }
|
|
146
|
+
},
|
|
147
|
+
footView: {
|
|
148
|
+
get(): HTMLDivElement { return that.footer.root }
|
|
149
|
+
},
|
|
150
|
+
sidebarView: {
|
|
151
|
+
get(): HTMLDivElement { return that.sideBar.root }
|
|
152
|
+
},
|
|
153
|
+
whiteboardView: {
|
|
154
|
+
get(): HTMLDivElement { return that.whiteboard.view }
|
|
155
|
+
},
|
|
156
|
+
slideView: {
|
|
157
|
+
get(): HTMLDivElement { return that.slideContainer }
|
|
158
|
+
},
|
|
159
|
+
pageIndex: {
|
|
160
|
+
get(): number { return that.currentSlideIndex }
|
|
161
|
+
},
|
|
162
|
+
pageCount: {
|
|
163
|
+
get(): number { return that.slideCount }
|
|
164
|
+
},
|
|
165
|
+
goto: {
|
|
166
|
+
...propertyConfig,
|
|
167
|
+
value: (pageIndex: number) => {
|
|
168
|
+
this.sideBar.emit("pageChange", pageIndex);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
nextStep: {
|
|
172
|
+
...propertyConfig,
|
|
173
|
+
value: () => {
|
|
174
|
+
this.footer.emit("nextStep");
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
prevStep: {
|
|
178
|
+
...propertyConfig,
|
|
179
|
+
value: () => {
|
|
180
|
+
this.footer.emit("prevStep");
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
nextPage: {
|
|
184
|
+
...propertyConfig,
|
|
185
|
+
value: () => {
|
|
186
|
+
this.footer.emit("nextPage");
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
prevPage: {
|
|
190
|
+
...propertyConfig,
|
|
191
|
+
value: () => {
|
|
192
|
+
this.footer.emit("prevPage");
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
sideBarToggle: {
|
|
196
|
+
...propertyConfig,
|
|
197
|
+
value: () => {
|
|
198
|
+
this.footer.emit("sideBarToggle");
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
imgContent: {
|
|
202
|
+
...propertyConfig,
|
|
203
|
+
value: (pageIndex: number) => {
|
|
204
|
+
return this.getImageContent(pageIndex);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
imgUrl: {
|
|
208
|
+
...propertyConfig,
|
|
209
|
+
value: (pageIndex: number) => {
|
|
210
|
+
return this.getImageUrl(pageIndex);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
imgSize: {
|
|
214
|
+
...propertyConfig,
|
|
215
|
+
value: (pageIndex: number) => {
|
|
216
|
+
return this.getImageSize(pageIndex);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
230
219
|
})
|
|
231
220
|
}
|
|
232
221
|
|
|
@@ -323,6 +312,26 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
|
|
315
|
+
private keyBoardEvents = (event: KeyboardEvent) => {
|
|
316
|
+
if (event.key === "ArrowLeft") {
|
|
317
|
+
this.footer.emit("prevStep");
|
|
318
|
+
} else if (event.key === "ArrowRight") {
|
|
319
|
+
this.footer.emit("nextStep");
|
|
320
|
+
} else if (event.key === "ArrowUp") {
|
|
321
|
+
this.footer.emit("prevPage");
|
|
322
|
+
} else if (event.key === "ArrowDown") {
|
|
323
|
+
this.footer.emit("nextPage");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private bindKeyBoardEvent() {
|
|
328
|
+
document.addEventListener("keydown", this.keyBoardEvents);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private unbindKeyBoarEvent() {
|
|
332
|
+
document.removeEventListener("keydown", this.keyBoardEvents);
|
|
333
|
+
}
|
|
334
|
+
|
|
326
335
|
public async initialize(option: SlideApplicationOption): Promise<void> {
|
|
327
336
|
this.prefix = option.prefix;
|
|
328
337
|
this.taskId = option.taskId;
|
|
@@ -390,35 +399,40 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
390
399
|
this.slide.setResource(option.taskId, option.prefix);
|
|
391
400
|
this.sideBar.initialize(json.slideCount, option);
|
|
392
401
|
|
|
393
|
-
this.slide.on(
|
|
402
|
+
this.slide.on(SLIDE_EVENTS.syncDispatch, event => {
|
|
394
403
|
this.getMap(this.name).set("syncSlide", {
|
|
395
404
|
slideState: this.slide.slideState,
|
|
396
405
|
dispatch: event,
|
|
397
406
|
})
|
|
398
407
|
})
|
|
399
408
|
|
|
400
|
-
this.slide.on(
|
|
409
|
+
this.slide.on(SLIDE_EVENTS.mainSeqStepStart, (animateIndex: number) => {
|
|
401
410
|
this.emitter.emit("mainSeqStepStart", animateIndex);
|
|
402
411
|
})
|
|
403
412
|
|
|
404
|
-
this.slide.on(
|
|
413
|
+
this.slide.on(SLIDE_EVENTS.mainSeqStepEnd, (animateIndex: number) => {
|
|
405
414
|
this.emitter.emit("mainSeqStepEnd", animateIndex);
|
|
406
415
|
})
|
|
407
416
|
|
|
408
|
-
this.slide.on(
|
|
417
|
+
this.slide.on(SLIDE_EVENTS.animateStart, () => {
|
|
418
|
+
this.sideBar.hidden();
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
this.slide.on(SLIDE_EVENTS.renderStart, (slideIndex) => {
|
|
409
422
|
this.whiteboardApp.emitter.view.style.opacity = "0";
|
|
410
423
|
this.whiteboardApp.emitter.addPage(`${slideIndex}`);
|
|
411
424
|
this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
|
|
412
425
|
this.emitter.emit("renderStart", slideIndex);
|
|
426
|
+
this.sideBar.hidden();
|
|
413
427
|
})
|
|
414
428
|
|
|
415
|
-
this.slide.on(
|
|
429
|
+
this.slide.on(SLIDE_EVENTS.renderEnd, (slideIndex) => {
|
|
416
430
|
this.currentSlideIndex = slideIndex;
|
|
417
431
|
this.whiteboardApp.emitter.view.style.opacity = "1";
|
|
418
432
|
this.emitter.emit("renderEnd", slideIndex);
|
|
419
433
|
});
|
|
420
434
|
|
|
421
|
-
this.slide.on(
|
|
435
|
+
this.slide.on(SLIDE_EVENTS.stateChange, (state) => {
|
|
422
436
|
this.getMap(this.name).set("slideState", state)
|
|
423
437
|
})
|
|
424
438
|
|
|
@@ -447,8 +461,30 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
447
461
|
}
|
|
448
462
|
}
|
|
449
463
|
});
|
|
450
|
-
this.permissions.addPermission(ForgeSlidePermissionFlag.all);
|
|
451
464
|
this.whiteboardApp.disableViewModel();
|
|
465
|
+
if (this.window) {
|
|
466
|
+
let prevStatus = "normal";
|
|
467
|
+
this.window.on("statusChange", (status) => {
|
|
468
|
+
if (prevStatus === "minimized") {
|
|
469
|
+
this.bindKeyBoardEvent();
|
|
470
|
+
prevStatus = status;
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
prevStatus = status;
|
|
474
|
+
if (status === "normal") {
|
|
475
|
+
this.bindKeyBoardEvent();
|
|
476
|
+
} else if (status === "minimized") {
|
|
477
|
+
this.unbindKeyBoarEvent();
|
|
478
|
+
}
|
|
479
|
+
})
|
|
480
|
+
this.window.on("focusedChange", (status) => {
|
|
481
|
+
if (status) {
|
|
482
|
+
this.bindKeyBoardEvent();
|
|
483
|
+
} else {
|
|
484
|
+
this.unbindKeyBoarEvent();
|
|
485
|
+
}
|
|
486
|
+
})
|
|
487
|
+
}
|
|
452
488
|
// @ts-ignore
|
|
453
489
|
window.__forge_slide = this;
|
|
454
490
|
// @ts-ignore
|
|
@@ -466,7 +502,6 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
|
|
|
466
502
|
this.slide.destroy();
|
|
467
503
|
this.sideBar.dispose();
|
|
468
504
|
this.getMap(this.name).unobserve(this.onSlideEventHandler)
|
|
469
|
-
return Promise.resolve(undefined);
|
|
470
505
|
}
|
|
471
506
|
|
|
472
507
|
}
|