@operato/board 0.2.16 → 0.2.27
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/CHANGELOG.md +43 -0
- package/custom-elements.json +9 -11
- package/demo/index-viewer.html +1 -1
- package/demo/index.html +3 -3
- package/dist/src/ox-board-player-style.d.ts +1 -1
- package/dist/src/ox-board-player-style.js +1 -1
- package/dist/src/ox-board-player-style.js.map +1 -1
- package/dist/src/ox-board-viewer.d.ts +10 -9
- package/dist/src/ox-board-viewer.js +74 -95
- package/dist/src/ox-board-viewer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/src/ox-board-player-style.ts +1 -1
- package/src/ox-board-viewer.ts +79 -100
- package/yarn-error.log +18355 -0
package/src/ox-board-viewer.ts
CHANGED
|
@@ -96,25 +96,25 @@ export class BoardViewer extends LitElement {
|
|
|
96
96
|
}
|
|
97
97
|
`
|
|
98
98
|
|
|
99
|
-
@property({ type: String }) baseUrl = ''
|
|
99
|
+
@property({ type: String }) baseUrl: string = ''
|
|
100
100
|
@property({ type: Object }) board: any = {}
|
|
101
101
|
@property({ type: Object }) provider: any = null
|
|
102
|
-
@property({ type: Object }) data
|
|
102
|
+
@property({ type: Object }) data: any
|
|
103
103
|
|
|
104
104
|
@property({ type: Boolean, reflect: true, attribute: 'hide-fullscreen' }) hideFullscreen = false
|
|
105
105
|
@property({ type: Boolean, reflect: true, attribute: 'hide-navigation' }) hideNavigation = false
|
|
106
106
|
|
|
107
|
-
@state()
|
|
108
|
-
@state()
|
|
109
|
-
@state()
|
|
107
|
+
@state() _scene: any = null
|
|
108
|
+
@state() _forward: Array<any> = []
|
|
109
|
+
@state() _backward: Array<any> = []
|
|
110
110
|
|
|
111
111
|
@state() _oldtarget?: HTMLElement
|
|
112
112
|
@state() _fade_animations?: Array<Animation>
|
|
113
113
|
|
|
114
|
-
@query('#target')
|
|
115
|
-
@query('#prev')
|
|
116
|
-
@query('#next')
|
|
117
|
-
@query('#fullscreen')
|
|
114
|
+
@query('#target') _target!: HTMLElement
|
|
115
|
+
@query('#prev') _prev!: HTMLElement
|
|
116
|
+
@query('#next') _next!: HTMLElement
|
|
117
|
+
@query('#fullscreen') _fullscreen!: HTMLElement
|
|
118
118
|
|
|
119
119
|
render() {
|
|
120
120
|
var fullscreen =
|
|
@@ -170,9 +170,11 @@ export class BoardViewer extends LitElement {
|
|
|
170
170
|
`
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
connectedCallback() {
|
|
174
|
+
super.connectedCallback()
|
|
175
|
+
|
|
174
176
|
window.addEventListener('resize', () => {
|
|
175
|
-
this.
|
|
177
|
+
this._scene && this._scene.fit()
|
|
176
178
|
})
|
|
177
179
|
|
|
178
180
|
this.renderRoot.addEventListener(
|
|
@@ -185,24 +187,30 @@ export class BoardViewer extends LitElement {
|
|
|
185
187
|
)
|
|
186
188
|
}
|
|
187
189
|
|
|
190
|
+
disconnectedCallback() {
|
|
191
|
+
super.disconnectedCallback()
|
|
192
|
+
|
|
193
|
+
this.closeScene()
|
|
194
|
+
}
|
|
195
|
+
|
|
188
196
|
updated(changes: PropertyValues<this>) {
|
|
189
197
|
if (changes.has('board')) {
|
|
198
|
+
this.closeScene()
|
|
199
|
+
|
|
190
200
|
if (this.board && this.board.id) {
|
|
191
201
|
this.initScene()
|
|
192
|
-
} else {
|
|
193
|
-
this.closeScene()
|
|
194
202
|
}
|
|
195
203
|
}
|
|
196
204
|
|
|
197
|
-
if (changes.has('data') && this.
|
|
198
|
-
this.
|
|
205
|
+
if (changes.has('data') && this._scene && this.data) {
|
|
206
|
+
this._scene.data = this.data
|
|
199
207
|
}
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
initScene() {
|
|
203
211
|
if (!this.board || !this.board.id) return
|
|
204
212
|
|
|
205
|
-
|
|
213
|
+
this._scene = create({
|
|
206
214
|
model: {
|
|
207
215
|
...this.board.model
|
|
208
216
|
},
|
|
@@ -211,70 +219,48 @@ export class BoardViewer extends LitElement {
|
|
|
211
219
|
})
|
|
212
220
|
|
|
213
221
|
if (this.baseUrl) {
|
|
214
|
-
|
|
222
|
+
this._scene.baseUrl = this.baseUrl
|
|
215
223
|
}
|
|
216
224
|
|
|
217
|
-
this.provider.add(this.board.id,
|
|
225
|
+
this.provider.add(this.board.id, this._scene)
|
|
218
226
|
|
|
219
|
-
this.
|
|
220
|
-
|
|
221
|
-
/* provider.add 시에 추가된 레퍼런스 카운트를 다운시켜주어야 함 */
|
|
222
|
-
scene.release()
|
|
227
|
+
this.setupScene(this._scene)
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
closeScene() {
|
|
226
|
-
if (this.
|
|
227
|
-
this.unbindSceneEvents(this.
|
|
231
|
+
if (this._scene) {
|
|
232
|
+
this.unbindSceneEvents(this._scene)
|
|
228
233
|
|
|
229
|
-
this.
|
|
230
|
-
this.
|
|
234
|
+
this._scene.target = null
|
|
235
|
+
this._scene.release()
|
|
231
236
|
|
|
232
|
-
|
|
237
|
+
this._scene = null
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
// delete queued scenes
|
|
236
|
-
this.
|
|
237
|
-
this.
|
|
241
|
+
this._forward.forEach(scene => scene.release())
|
|
242
|
+
this._forward = []
|
|
238
243
|
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
244
|
+
this._backward.forEach(scene => scene.release())
|
|
245
|
+
this._backward = []
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
releaseScene() {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.scene.target = null
|
|
248
|
-
this.scene.release()
|
|
249
|
-
|
|
250
|
-
delete this.scene
|
|
251
|
-
|
|
252
|
-
// delete queued scenes
|
|
253
|
-
this.forward.forEach(scene => {
|
|
254
|
-
scene.release()
|
|
255
|
-
})
|
|
256
|
-
this.forward = []
|
|
257
|
-
|
|
258
|
-
this.backward.forEach(scene => {
|
|
259
|
-
scene.release()
|
|
260
|
-
})
|
|
261
|
-
this.backward = []
|
|
262
|
-
|
|
263
|
-
this.transientShowButtons()
|
|
264
|
-
}
|
|
249
|
+
this.closeScene()
|
|
250
|
+
this.transientShowButtons()
|
|
265
251
|
}
|
|
266
252
|
|
|
267
253
|
setupScene(scene: any) {
|
|
268
|
-
this.
|
|
254
|
+
this._scene = scene
|
|
269
255
|
|
|
270
256
|
/* scene의 기존 target을 보관한다. */
|
|
271
|
-
this._oldtarget = this.
|
|
257
|
+
this._oldtarget = this._scene.target
|
|
272
258
|
|
|
273
|
-
this.
|
|
274
|
-
this.
|
|
259
|
+
this._scene.fit(this.board.model.fitMode)
|
|
260
|
+
this._scene.target = this._target
|
|
275
261
|
|
|
276
262
|
if (this.data) {
|
|
277
|
-
this.
|
|
263
|
+
this._scene.data = this.data
|
|
278
264
|
}
|
|
279
265
|
|
|
280
266
|
this.bindSceneEvents()
|
|
@@ -288,28 +274,25 @@ export class BoardViewer extends LitElement {
|
|
|
288
274
|
try {
|
|
289
275
|
var scene = await this.provider.get(boardId, true)
|
|
290
276
|
|
|
291
|
-
|
|
292
|
-
this.scene = scene
|
|
293
|
-
|
|
294
|
-
if (scene.target === this.target) {
|
|
277
|
+
if (scene === this._scene) {
|
|
295
278
|
scene.release()
|
|
296
279
|
return
|
|
297
280
|
}
|
|
298
281
|
|
|
299
|
-
if (
|
|
300
|
-
/* old scene을
|
|
301
|
-
this.unbindSceneEvents(
|
|
282
|
+
if (this._scene) {
|
|
283
|
+
/* old scene을 _backward에 보관한다. */
|
|
284
|
+
this.unbindSceneEvents(this._scene)
|
|
302
285
|
/* 원래의 target에 되돌린다. */
|
|
303
|
-
|
|
304
|
-
this.
|
|
286
|
+
this._scene.target = this._oldtarget
|
|
287
|
+
this._backward.push(this._scene)
|
|
305
288
|
}
|
|
306
289
|
|
|
307
|
-
this.
|
|
308
|
-
|
|
309
|
-
|
|
290
|
+
this._scene = scene
|
|
291
|
+
|
|
292
|
+
this._forward.forEach(scene => scene.release())
|
|
310
293
|
|
|
311
294
|
/* forward를 비운다. */
|
|
312
|
-
this.
|
|
295
|
+
this._forward = []
|
|
313
296
|
|
|
314
297
|
this.setupScene(scene)
|
|
315
298
|
|
|
@@ -322,10 +305,10 @@ export class BoardViewer extends LitElement {
|
|
|
322
305
|
}
|
|
323
306
|
|
|
324
307
|
bindSceneEvents() {
|
|
325
|
-
this.
|
|
326
|
-
this.
|
|
327
|
-
this.
|
|
328
|
-
this.
|
|
308
|
+
this._scene.on('goto', this.onLinkGoto, this)
|
|
309
|
+
this._scene.on('link-open', this.onLinkOpen, this)
|
|
310
|
+
this._scene.on('link-move', this.onLinkMove, this)
|
|
311
|
+
this._scene.on('route-page', this.onRoutePage, this)
|
|
329
312
|
}
|
|
330
313
|
|
|
331
314
|
unbindSceneEvents(scene: any) {
|
|
@@ -337,8 +320,8 @@ export class BoardViewer extends LitElement {
|
|
|
337
320
|
|
|
338
321
|
transientShowButtons(stop?: boolean) {
|
|
339
322
|
var buttons = []
|
|
340
|
-
!this.hideNavigation && buttons.push(this.
|
|
341
|
-
!this.hideFullscreen && buttons.push(this.
|
|
323
|
+
!this.hideNavigation && buttons.push(this._next, this._prev)
|
|
324
|
+
!this.hideFullscreen && buttons.push(this._fullscreen)
|
|
342
325
|
|
|
343
326
|
if (buttons.length == 0) {
|
|
344
327
|
return
|
|
@@ -367,9 +350,9 @@ export class BoardViewer extends LitElement {
|
|
|
367
350
|
})
|
|
368
351
|
}
|
|
369
352
|
|
|
370
|
-
this.
|
|
371
|
-
this.
|
|
372
|
-
this.
|
|
353
|
+
this._forward.length <= 0 ? this._next.setAttribute('hidden', '') : this._next.removeAttribute('hidden')
|
|
354
|
+
this._backward.length <= 0 ? this._prev.setAttribute('hidden', '') : this._prev.removeAttribute('hidden')
|
|
355
|
+
this._fullscreen && this._fullscreen.removeAttribute('hidden')
|
|
373
356
|
|
|
374
357
|
this._fade_animations.forEach(animation => {
|
|
375
358
|
animation.cancel()
|
|
@@ -382,30 +365,30 @@ export class BoardViewer extends LitElement {
|
|
|
382
365
|
/* event handlers */
|
|
383
366
|
|
|
384
367
|
onTapNext() {
|
|
385
|
-
var scene = this.
|
|
368
|
+
var scene = this._forward.pop()
|
|
386
369
|
if (!scene) return
|
|
387
370
|
|
|
388
|
-
if (this.
|
|
389
|
-
this.
|
|
371
|
+
if (this._scene) {
|
|
372
|
+
this._scene.target = null
|
|
390
373
|
/* 원래의 target에 되돌린다. */
|
|
391
|
-
this.
|
|
392
|
-
this.unbindSceneEvents(this.
|
|
393
|
-
this.
|
|
374
|
+
this._scene.target = this._oldtarget
|
|
375
|
+
this.unbindSceneEvents(this._scene)
|
|
376
|
+
this._backward.push(this._scene)
|
|
394
377
|
}
|
|
395
378
|
|
|
396
379
|
this.setupScene(scene)
|
|
397
380
|
}
|
|
398
381
|
|
|
399
382
|
onTapPrev() {
|
|
400
|
-
var scene = this.
|
|
383
|
+
var scene = this._backward.pop()
|
|
401
384
|
if (!scene) return
|
|
402
385
|
|
|
403
|
-
if (this.
|
|
404
|
-
this.
|
|
386
|
+
if (this._scene) {
|
|
387
|
+
this._scene.target = null
|
|
405
388
|
/* 원래의 target에 되돌린다. */
|
|
406
|
-
this.
|
|
407
|
-
this.unbindSceneEvents(this.
|
|
408
|
-
this.
|
|
389
|
+
this._scene.target = this._oldtarget
|
|
390
|
+
this.unbindSceneEvents(this._scene)
|
|
391
|
+
this._forward.push(this._scene)
|
|
409
392
|
}
|
|
410
393
|
|
|
411
394
|
this.setupScene(scene)
|
|
@@ -414,12 +397,8 @@ export class BoardViewer extends LitElement {
|
|
|
414
397
|
onTapFullscreen() {
|
|
415
398
|
togglefullscreen(
|
|
416
399
|
this,
|
|
417
|
-
() =>
|
|
418
|
-
|
|
419
|
-
},
|
|
420
|
-
() => {
|
|
421
|
-
this.requestUpdate()
|
|
422
|
-
}
|
|
400
|
+
() => this.requestUpdate(),
|
|
401
|
+
() => this.requestUpdate()
|
|
423
402
|
)
|
|
424
403
|
}
|
|
425
404
|
|
|
@@ -461,11 +440,11 @@ export class BoardViewer extends LitElement {
|
|
|
461
440
|
}
|
|
462
441
|
|
|
463
442
|
async getSceneImageData(base64 = false) {
|
|
464
|
-
if (!this.
|
|
443
|
+
if (!this._scene) {
|
|
465
444
|
return
|
|
466
445
|
}
|
|
467
446
|
|
|
468
|
-
var { width, height } = this.
|
|
447
|
+
var { width, height } = this._scene.model
|
|
469
448
|
var pixelRatio = window.devicePixelRatio
|
|
470
449
|
|
|
471
450
|
// 1. Scene의 바운드에 근거하여, 오프스크린 캔바스를 만든다.
|
|
@@ -473,7 +452,7 @@ export class BoardViewer extends LitElement {
|
|
|
473
452
|
canvas.width = Number(width)
|
|
474
453
|
canvas.height = Number(height)
|
|
475
454
|
|
|
476
|
-
var root = this.
|
|
455
|
+
var root = this._scene.root
|
|
477
456
|
// 2. 모델레이어의 원래 위치와 스케일을 저장한다.
|
|
478
457
|
var translate = root.get('translate')
|
|
479
458
|
var scale = root.get('scale')
|