@sedoo/unidoo 0.1.71 → 0.1.72

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,27 +1,26 @@
1
1
  <template>
2
2
  <div>
3
-
4
3
  <div player-layout elevation="0" :class="{ zoomed: isZoomed }">
5
-
6
4
  <div mask @click="zoomPlayer"></div>
7
5
 
8
6
  <div body>
9
-
10
7
  <div sub-body :style="subBodyStyle">
11
-
12
- <v-divider style="order: 1;"></v-divider>
8
+ <v-divider style="order: 1"></v-divider>
13
9
 
14
- <v-row viewer-part :style="{ order: ((playerBarTop) ? 2 : 4) }">
15
-
16
- <v-list-item player-layout-slider-part >
10
+ <v-row viewer-part :style="{ order: playerBarTop ? 2 : 4 }">
11
+ <v-list-item player-layout-slider-part>
17
12
  <div style="display: flex; flex-direction: column; width: 100%">
18
- <div custom-top-left >
13
+ <div custom-top-left>
19
14
  <slot name="customField"></slot>
20
15
  </div>
21
- <div style="display: flex; justify-content: center; margin-top: 10px;">
22
- <slot name="frameTitle">
23
-
24
- </slot>
16
+ <div
17
+ style="
18
+ display: flex;
19
+ justify-content: center;
20
+ margin-top: 10px;
21
+ "
22
+ >
23
+ <slot name="frameTitle"> </slot>
25
24
  </div>
26
25
 
27
26
  <v-btn
@@ -35,15 +34,18 @@
35
34
  >
36
35
  <v-icon>mdi-cached</v-icon>
37
36
  </v-btn>
38
-
39
- <unidoo-progress-bar v-if="showProgressBar"
37
+
38
+ <unidoo-progress-bar
39
+ v-if="showProgressBar"
40
40
  :title="progressBarTitle"
41
41
  :current="loadedFrames"
42
- :max="max + 1">
42
+ :max="max + 1"
43
+ >
43
44
  </unidoo-progress-bar>
44
45
 
45
- <v-slider v-else-if="canPlay"
46
- style="margin-top: -10px; padding: 0 5px;"
46
+ <v-slider
47
+ v-else-if="canPlay"
48
+ style="margin-top: -10px; padding: 0 5px"
47
49
  v-model="value"
48
50
  ref="slider"
49
51
  :id="id"
@@ -57,58 +59,88 @@
57
59
  >
58
60
  <template v-slot:prepend>
59
61
  <div buttons>
60
-
61
- <v-btn color="primary" fab x-small dark style="margin-right: 5px;" @click="previous">
62
+ <v-btn
63
+ color="primary"
64
+ fab
65
+ x-small
66
+ dark
67
+ style="margin-right: 5px"
68
+ @click="previous"
69
+ >
62
70
  <v-icon>mdi-skip-previous</v-icon>
63
71
  </v-btn>
64
72
 
65
- <v-btn v-if="!isPlaying" color="primary" fab small dark @click="clicPlay">
73
+ <v-btn
74
+ v-if="!isPlaying"
75
+ color="primary"
76
+ fab
77
+ small
78
+ dark
79
+ @click="clicPlay"
80
+ >
66
81
  <v-icon>mdi-play</v-icon>
67
82
  </v-btn>
68
83
 
69
- <v-btn v-if="isPlaying" color="primary" fab small dark @click="clickStop">
84
+ <v-btn
85
+ v-if="isPlaying"
86
+ color="primary"
87
+ fab
88
+ small
89
+ dark
90
+ @click="clickStop"
91
+ >
70
92
  <v-icon>mdi-stop</v-icon>
71
93
  </v-btn>
72
94
 
73
- <v-btn color="primary" fab x-small dark style="margin-left: 5px;" @click="next">
95
+ <v-btn
96
+ color="primary"
97
+ fab
98
+ x-small
99
+ dark
100
+ style="margin-left: 5px"
101
+ @click="next"
102
+ >
74
103
  <v-icon>mdi-skip-next</v-icon>
75
104
  </v-btn>
76
-
77
105
  </div>
78
-
79
106
  </template>
80
107
  </v-slider>
81
108
 
82
- <iframe ref="sizeHandlerIframe" src="about:blank" style="width:100%; height:0; border:0;"></iframe>
109
+ <iframe
110
+ ref="sizeHandlerIframe"
111
+ src="about:blank"
112
+ style="width: 100%; height: 0; border: 0"
113
+ ></iframe>
83
114
  </div>
84
115
  </v-list-item>
85
-
86
116
  </v-row>
87
117
 
88
- <v-divider style="order: 3;"></v-divider>
118
+ <v-divider style="order: 3"></v-divider>
89
119
 
90
- <v-row player-part :style="{ order: ((playerBarTop) ? 4 : 2) }">
91
-
92
- <v-list-item player-layout-displayer v-if="clickableFrame" :ripple="false" @click="playOrStopFrame">
120
+ <v-row player-part :style="{ order: playerBarTop ? 4 : 2 }">
121
+ <v-list-item
122
+ player-layout-displayer
123
+ v-if="clickableFrame"
124
+ :ripple="false"
125
+ @click="playOrStopFrame"
126
+ >
93
127
  <div viewer-container>
94
128
  <div viewer-slot-container>
95
129
  <slot name="displayer"></slot>
96
130
  </div>
97
131
  </div>
98
-
99
132
  </v-list-item>
100
133
 
101
- <div v-else player-layout-displayer >
134
+ <div v-else player-layout-displayer>
102
135
  <div viewer-container>
103
136
  <div viewer-slot-container>
104
137
  <slot name="displayer"></slot>
105
138
  </div>
106
139
  </div>
107
140
  </div>
108
-
109
141
  </v-row>
110
142
 
111
- <v-divider style="order: 5;"></v-divider>
143
+ <v-divider style="order: 5"></v-divider>
112
144
  </div>
113
145
  </div>
114
146
  <thumbnail-entries
@@ -117,18 +149,16 @@
117
149
  :entries="entries"
118
150
  :thumbnailRatio="thumbnailRatio"
119
151
  @select="updateFromThumbnail"
120
- ></thumbnail-entries>
152
+ ></thumbnail-entries>
121
153
  </div>
122
154
  </div>
123
-
124
155
  </template>
125
156
 
126
157
  <script>
127
- import Vue from 'vue'
158
+ import Vue from "vue";
128
159
  import ThumbnailEntries from "./ThumbnailEntries.vue";
129
160
 
130
161
  export default {
131
-
132
162
  components: {
133
163
  ThumbnailEntries
134
164
  },
@@ -142,7 +172,7 @@ export default {
142
172
  graduation: { type: Array, default: () => [] },
143
173
  loop: { type: Boolean, default: false },
144
174
  loadedFrames: { type: Number, default: null },
145
- progressBarTitle: { type: String, default: 'Loading image' },
175
+ progressBarTitle: { type: String, default: "Loading image" },
146
176
  clickableFrame: { type: Boolean, default: true },
147
177
  playerBarTop: { type: Boolean, default: true },
148
178
  entries: { type: Array, default: () => [] },
@@ -162,46 +192,52 @@ export default {
162
192
 
163
193
  computed: {
164
194
  showProgressBar() {
165
- return this.max != null && this.loadedFrames != null && this.loadedFrames < this.max + 1
195
+ return (
196
+ this.max != null &&
197
+ this.loadedFrames != null &&
198
+ this.loadedFrames < this.max + 1
199
+ );
166
200
  },
167
201
 
168
202
  canPlay() {
169
- return this.max > 0 && this.loadedFrames >= this.max + 1
203
+ return this.max > 0 && this.loadedFrames >= this.max + 1;
170
204
  },
171
205
 
172
206
  subBodyStyle() {
173
- const vh = (this.isZoomed) ? '75vh' : '43vh';
174
- return { gridTemplateRows: ((this.playerBarTop) ? '10px 120px 10px ' + vh + ' 10px' : '10px ' + vh + ' 10px 120px 10px') };
207
+ const vh = this.isZoomed ? "75vh" : "43vh";
208
+ return {
209
+ gridTemplateRows: this.playerBarTop
210
+ ? "10px 120px 10px " + vh + " 10px"
211
+ : "10px " + vh + " 10px 120px 10px"
212
+ };
175
213
  }
176
-
177
214
  },
178
215
 
179
216
  watch: {
180
-
181
217
  initialValue(val) {
182
218
  this.value = val;
183
219
  },
184
220
 
185
221
  value(val) {
186
- this.$emit('input', val);
222
+ this.$emit("input", val);
187
223
  },
188
224
 
189
225
  canPlay(val) {
190
- if (val) {
226
+ if (val && typeof document !== "undefined") {
191
227
  // trick used to init wrapper v-app to the slider (app field) after its initialization in case of multi instance vuetify
192
228
  const self = this;
193
229
  Vue.nextTick(() => {
194
230
  if (self.$refs.slider) {
195
231
  const slider = self.$refs.slider;
196
- const apps = document.querySelectorAll('[data-app]');
197
- apps.forEach(elem => {
232
+ const apps = document.querySelectorAll("[data-app]");
233
+ apps.forEach((elem) => {
198
234
  if (elem.contains(slider.$el)) {
199
235
  slider.app = elem;
200
236
  }
201
237
  });
202
238
  }
203
239
  self.focusSlider();
204
- })
240
+ });
205
241
  }
206
242
  },
207
243
 
@@ -212,24 +248,27 @@ export default {
212
248
  sliderSize() {
213
249
  this.initGraduation();
214
250
  }
215
-
216
251
  },
217
252
 
218
253
  created() {
219
- this.playerListener = this.handlePlay.bind(this);
220
- document.addEventListener('play-stop', this.playerListener);
221
- this.barListener = this.keyHandler.bind(this);
222
- document.addEventListener('keyup', this.barListener);
254
+ if (typeof document !== "undefined") {
255
+ this.playerListener = this.handlePlay.bind(this);
256
+ document.addEventListener("play-stop", this.playerListener);
257
+ this.barListener = this.keyHandler.bind(this);
258
+ document.addEventListener("keyup", this.barListener);
259
+ }
223
260
  },
224
261
 
225
262
  mounted() {
226
- this.id = this.create_UUID();
227
- this.value = this.initialValue;
228
- if (this.autoPlay) {
229
- this.play();
263
+ if (typeof document !== "undefined") {
264
+ this.id = this.create_UUID();
265
+ this.value = this.initialValue;
266
+ if (this.autoPlay) {
267
+ this.play();
268
+ }
269
+ document.dispatchEvent(new CustomEvent("show-play"));
270
+ this.initIframe();
230
271
  }
231
- document.dispatchEvent(new CustomEvent('show-play'));
232
- this.initIframe();
233
272
  },
234
273
 
235
274
  beforeDestroy() {
@@ -238,11 +277,13 @@ export default {
238
277
  },
239
278
 
240
279
  destroyed() {
241
- document.dispatchEvent(new CustomEvent('remove-player'));
242
- document.removeEventListener('play-stop', this.playerListener);
243
- this.playerListener = null;
244
- document.removeEventListener('keyup', this.barListener);
245
- this.barListener = null;
280
+ if (typeof document !== "undefined") {
281
+ document.dispatchEvent(new CustomEvent("remove-player"));
282
+ document.removeEventListener("play-stop", this.playerListener);
283
+ this.playerListener = null;
284
+ document.removeEventListener("keyup", this.barListener);
285
+ this.barListener = null;
286
+ }
246
287
  },
247
288
 
248
289
  methods: {
@@ -281,7 +322,7 @@ export default {
281
322
  this.clickedValue = -1;
282
323
  clearInterval(this.timeInterval);
283
324
  },
284
-
325
+
285
326
  clickStop() {
286
327
  this.stop();
287
328
  this.focusSlider();
@@ -354,7 +395,7 @@ export default {
354
395
  this.reinit();
355
396
  }
356
397
  },
357
-
398
+
358
399
  restart() {
359
400
  this.reinit();
360
401
  if (this.autoPlay) {
@@ -364,7 +405,7 @@ export default {
364
405
 
365
406
  emitReloadFrames() {
366
407
  this.stop();
367
- this.$emit('reload-frames');
408
+ this.$emit("reload-frames");
368
409
  },
369
410
 
370
411
  initGraduation() {
@@ -374,27 +415,29 @@ export default {
374
415
  let delta = 1;
375
416
  if (this.sliderSize && gradsLength && this.graduation[0]) {
376
417
  const firstGrad = this.graduation[0].length * 9; // nb chars * number of pixels for 1 character
377
- let exceed = Math.ceil(this.sliderSize - (gradsLength * firstGrad) - 30); // add 30px of margin
378
- exceed = (exceed < 0) ? -exceed : 0;
418
+ let exceed = Math.ceil(
419
+ this.sliderSize - gradsLength * firstGrad - 30
420
+ ); // add 30px of margin
421
+ exceed = exceed < 0 ? -exceed : 0;
379
422
  const gradsExceed = exceed / firstGrad;
380
423
  if (gradsLength - gradsExceed) {
381
- delta = Math.ceil(gradsLength / (gradsLength - gradsExceed));
424
+ delta = Math.ceil(gradsLength / (gradsLength - gradsExceed));
382
425
  } else {
383
426
  delta = Math.ceil(gradsLength);
384
427
  }
385
428
  }
386
429
 
387
430
  let n = 0;
388
- this.graduation.forEach(element => {
431
+ this.graduation.forEach((element) => {
389
432
  if (n % delta) {
390
433
  result.push(null);
391
- } else {
434
+ } else {
392
435
  result.push(element);
393
436
  }
394
437
  n++;
395
438
  });
396
- }
397
-
439
+ }
440
+
398
441
  this.filteredGraduation = result;
399
442
  },
400
443
 
@@ -405,7 +448,7 @@ export default {
405
448
  this.sliderSize = box.width - 114 - 9 - 32 - 10; // - padding and margin
406
449
  const iframeWin = iframe.contentWindow;
407
450
  this.resizeListener = this.handleResize.bind(this);
408
- iframeWin.addEventListener('resize', this.resizeListener);
451
+ iframeWin.addEventListener("resize", this.resizeListener);
409
452
  }
410
453
  },
411
454
 
@@ -414,7 +457,7 @@ export default {
414
457
  if (iframe) {
415
458
  const iframeWin = iframe.contentWindow;
416
459
  if (iframeWin) {
417
- iframeWin.removeEventListener('resize', this.resizeListener);
460
+ iframeWin.removeEventListener("resize", this.resizeListener);
418
461
  }
419
462
  this.resizeListener = null;
420
463
  }
@@ -438,11 +481,14 @@ export default {
438
481
 
439
482
  create_UUID() {
440
483
  var dt = new Date().getTime();
441
- var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
484
+ var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
485
+ /[xy]/g,
486
+ function (c) {
442
487
  var r = (dt + Math.random() * 16) % 16 | 0;
443
488
  dt = Math.floor(dt / 16);
444
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
445
- });
489
+ return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
490
+ }
491
+ );
446
492
  return uuid;
447
493
  },
448
494
 
@@ -456,10 +502,10 @@ export default {
456
502
 
457
503
  keyHandler(e) {
458
504
  if (this.isPlaying) {
459
- if (e.keyCode === '37') {
505
+ if (e.keyCode === "37") {
460
506
  // left arrow
461
507
  this.previous();
462
- } else if (e.keyCode === '39') {
508
+ } else if (e.keyCode === "39") {
463
509
  // right arrow
464
510
  this.clickStop();
465
511
  }
@@ -472,168 +518,165 @@ export default {
472
518
  this.play();
473
519
  } else {
474
520
  this.stop();
475
- }
521
+ }
476
522
  }
477
523
  }
478
-
479
524
  }
480
- }
525
+ };
481
526
  </script>
482
527
  <style scoped>
483
- [player-layout] [body] {
484
- display: flex;
485
- flex-direction: column;
486
- justify-content: center;
487
- height: 100%;
488
- max-width: 91vw;
489
- background: white;
490
- transition: opacity 0.2s ease-in-out;
491
- transition: margin 0.2s ease-in-out;
492
- }
493
-
494
- [player-layout] [body] [sub-body] {
495
- display: grid;
496
- background: white;
497
- align-items: center;
498
- }
528
+ [player-layout] [body] {
529
+ display: flex;
530
+ flex-direction: column;
531
+ justify-content: center;
532
+ height: 100%;
533
+ max-width: 91vw;
534
+ background: white;
535
+ transition: opacity 0.2s ease-in-out;
536
+ transition: margin 0.2s ease-in-out;
537
+ }
499
538
 
500
- [player-layout] [mask] {
501
- position: fixed;
502
- visibility: hidden;
503
- z-index: 99998;
504
- top: 0px;
505
- left: 0px;
506
- right: 0px;
507
- bottom: 0px;
508
- background: rgb(0,0,0);
509
- opacity: 0;
510
- transition: all 0.2s;
511
- }
539
+ [player-layout] [body] [sub-body] {
540
+ display: grid;
541
+ background: white;
542
+ align-items: center;
543
+ }
512
544
 
513
- [viewer-part] {
514
- margin-top: 0;
515
- margin-bottom: 0;
516
- height: 100%;
517
- }
545
+ [player-layout] [mask] {
546
+ position: fixed;
547
+ visibility: hidden;
548
+ z-index: 99998;
549
+ top: 0px;
550
+ left: 0px;
551
+ right: 0px;
552
+ bottom: 0px;
553
+ background: rgb(0, 0, 0);
554
+ opacity: 0;
555
+ transition: all 0.2s;
556
+ }
518
557
 
519
- [player-layout-slider-part] {
520
- position: relative;
521
- margin: 10px 0;
522
- max-height: 100%;
523
- }
558
+ [viewer-part] {
559
+ margin-top: 0;
560
+ margin-bottom: 0;
561
+ height: 100%;
562
+ }
524
563
 
525
- [player-layout-slider-part] [custom-top-left]{
526
- position: absolute;
527
- top: -5px;
528
- left: 30px;
529
- }
564
+ [player-layout-slider-part] {
565
+ position: relative;
566
+ margin: 10px 0;
567
+ max-height: 100%;
568
+ }
530
569
 
531
- [player-part] [player-layout-displayer] {
532
- height: 100%;
533
- width: 100%;
534
- }
570
+ [player-layout-slider-part] [custom-top-left] {
571
+ position: absolute;
572
+ top: -5px;
573
+ left: 30px;
574
+ }
535
575
 
536
- [player-layout] [viewer-container] {
537
- display: flex;
538
- height: inherit;
539
- width: 100%;
540
- overflow: auto;
541
- }
576
+ [player-part] [player-layout-displayer] {
577
+ height: 100%;
578
+ width: 100%;
579
+ }
542
580
 
543
- [player-layout] [viewer-container] [viewer-slot-container] {
544
- display: flex;
545
- justify-content: center;
546
- height: 100%;
547
- width: 100%;
548
- margin:auto;
549
- }
581
+ [player-layout] [viewer-container] {
582
+ display: flex;
583
+ height: inherit;
584
+ width: 100%;
585
+ overflow: auto;
586
+ }
550
587
 
551
- [player-layout].zoomed [viewer-container] [viewer-slot-container] {
552
- height: fit-content;
553
- }
588
+ [player-layout] [viewer-container] [viewer-slot-container] {
589
+ display: flex;
590
+ justify-content: center;
591
+ height: 100%;
592
+ width: 100%;
593
+ margin: auto;
594
+ }
554
595
 
555
- [buttons] {
556
- display: flex;
557
- align-items: baseline;
558
- }
596
+ [player-layout].zoomed [viewer-container] [viewer-slot-container] {
597
+ height: fit-content;
598
+ }
559
599
 
560
- .v-input__slider {
561
- align-items: center;
562
- }
600
+ [buttons] {
601
+ display: flex;
602
+ align-items: baseline;
603
+ }
563
604
 
564
- [reload-button] {
565
- position: absolute;
566
- top: -5px;
567
- right: 15px;
568
- }
605
+ .v-input__slider {
606
+ align-items: center;
607
+ }
569
608
 
570
- [player-layout].zoomed [body] {
571
- position: fixed;
572
- display: block;
573
- z-index: 99999;
574
- top: 4vh;
575
- left: 4vw;
576
- right: 4vw;
577
- overflow: auto;
578
- margin-top: -5px;
579
- margin-bottom: 5px;
580
- padding-left : 15px;
581
- padding-right : 15px;
582
- height: auto;
583
- max-height: 92vh;
584
- border-radius: 5px;
585
- }
609
+ [reload-button] {
610
+ position: absolute;
611
+ top: -5px;
612
+ right: 15px;
613
+ }
586
614
 
587
- [player-layout].zoomed [mask] {
588
- visibility: visible;
589
- opacity: 0.3;
590
- }
615
+ [player-layout].zoomed [body] {
616
+ position: fixed;
617
+ display: block;
618
+ z-index: 99999;
619
+ top: 4vh;
620
+ left: 4vw;
621
+ right: 4vw;
622
+ overflow: auto;
623
+ margin-top: -5px;
624
+ margin-bottom: 5px;
625
+ padding-left: 15px;
626
+ padding-right: 15px;
627
+ height: auto;
628
+ max-height: 92vh;
629
+ border-radius: 5px;
630
+ }
591
631
 
592
- [player-layout] [player-part] {
593
- height: 100%;
594
- margin-top: 0;
595
- margin-bottom: 0;
596
- }
632
+ [player-layout].zoomed [mask] {
633
+ visibility: visible;
634
+ opacity: 0.3;
635
+ }
597
636
 
598
- [player-layout].zoomed [player-part] {
599
- min-height: 60vh;
600
- }
601
- [player-layout].zoomed [player-part] [player-layout-displayer] {
602
- padding: 0;
603
- }
637
+ [player-layout] [player-part] {
638
+ height: 100%;
639
+ margin-top: 0;
640
+ margin-bottom: 0;
641
+ }
604
642
 
605
- @media screen and (max-width: 890px) {
643
+ [player-layout].zoomed [player-part] {
644
+ min-height: 60vh;
645
+ }
646
+ [player-layout].zoomed [player-part] [player-layout-displayer] {
647
+ padding: 0;
648
+ }
606
649
 
607
- [player-part] {
608
- flex-direction: column-reverse;
609
- }
650
+ @media screen and (max-width: 890px) {
651
+ [player-part] {
652
+ flex-direction: column-reverse;
653
+ }
610
654
 
611
- [displayer-part] {
612
- flex: 0 0 100%;
613
- max-width: 100%;
614
- }
615
-
616
- [viewer-part] {
617
- flex-direction: column;
618
- }
655
+ [displayer-part] {
656
+ flex: 0 0 100%;
657
+ max-width: 100%;
658
+ }
619
659
 
620
- [slider-part] {
621
- flex: 0 0 100%;
622
- max-width: 100%;
623
- }
660
+ [viewer-part] {
661
+ flex-direction: column;
624
662
  }
625
663
 
664
+ [slider-part] {
665
+ flex: 0 0 100%;
666
+ max-width: 100%;
667
+ }
668
+ }
626
669
  </style>
627
670
  <style>
628
- [player-layout] .v-slider__tick-label {
629
- font-size: 0.65em;
630
- }
671
+ [player-layout] .v-slider__tick-label {
672
+ font-size: 0.65em;
673
+ }
631
674
 
632
- [player-layout] .v-slider__tick {
633
- cursor: pointer;
634
- }
675
+ [player-layout] .v-slider__tick {
676
+ cursor: pointer;
677
+ }
635
678
 
636
- [player-layout] .v-slider--horizontal .v-slider__tick .v-slider__tick-label {
637
- top: 12px;
638
- }
639
- </style>
679
+ [player-layout] .v-slider--horizontal .v-slider__tick .v-slider__tick-label {
680
+ top: 12px;
681
+ }
682
+ </style>