|
29 | 29 | <!-- Modal view rendering --> |
30 | 30 | <NcModal v-else-if="initiated || currentFile.modal" |
31 | 31 | id="viewer" |
| 32 | + ref="modal" |
32 | 33 | :additional-trap-elements="trapElements" |
33 | 34 | :class="modalClass" |
34 | 35 | :clear-view-delay="-1 /* disable fade-out because of accessibility reasons */" |
|
37 | 38 | :light-backdrop="lightBackdrop" |
38 | 39 | :data-handler="handlerId" |
39 | 40 | :enable-slideshow="hasPrevious || hasNext" |
40 | | - :slideshow-paused="editing" |
| 41 | + :slideshow-paused="editing || playingVideo" |
41 | 42 | :enable-swipe="canSwipe && !editing" |
42 | 43 | :has-next="hasNext" |
43 | 44 | :has-previous="hasPrevious" |
|
150 | 151 | :loaded.sync="currentFile.loaded" |
151 | 152 | class="viewer__file viewer__file--active" |
152 | 153 | @update:editing="toggleEditor" |
| 154 | + @update:playing="playingVideo = $event" |
153 | 155 | @error="currentFailed" /> |
154 | 156 | <Error v-else |
155 | 157 | :name="currentFile.basename" /> |
@@ -257,6 +259,8 @@ export default defineComponent({ |
257 | 259 | isLoaded: false, |
258 | 260 | initiated: false, |
259 | 261 | editing: false, |
| 262 | + slideshowStarted: false, |
| 263 | + playingVideo: false, |
260 | 264 |
|
261 | 265 | // cancellable requests |
262 | 266 | cancelRequestFile: () => {}, |
@@ -313,6 +317,9 @@ export default defineComponent({ |
313 | 317 | canLoop() { |
314 | 318 | return this.Viewer.canLoop |
315 | 319 | }, |
| 320 | + startSlideshow() { |
| 321 | + return this.Viewer.startSlideshow |
| 322 | + }, |
316 | 323 | isStartOfList() { |
317 | 324 | return this.currentIndex === 0 |
318 | 325 | }, |
@@ -428,6 +435,12 @@ export default defineComponent({ |
428 | 435 | }, |
429 | 436 |
|
430 | 437 | watch: { |
| 438 | + fileList(fileList) { |
| 439 | + if (fileList.length > 1) { |
| 440 | + this.beginSlideshow() |
| 441 | + } |
| 442 | + }, |
| 443 | +
|
431 | 444 | el(element) { |
432 | 445 | logger.info(element) |
433 | 446 | this.$nextTick(() => { |
@@ -623,6 +636,34 @@ export default defineComponent({ |
623 | 636 | } |
624 | 637 | }, |
625 | 638 |
|
| 639 | + async beginSlideshow() { |
| 640 | + if (!this.startSlideshow || this.slideshowStarted) { |
| 641 | + return |
| 642 | + } |
| 643 | + this.slideshowStarted = true |
| 644 | +
|
| 645 | + // Hack: NcModal is imported lazily, so its ref is only there once the chunk |
| 646 | + // has resolved and it has been rendered. |
| 647 | + await NcModal() |
| 648 | + await this.$nextTick() |
| 649 | + if (!this.$refs.modal) { |
| 650 | + await this.$nextTick() |
| 651 | + } |
| 652 | +
|
| 653 | + // const modal = this.$refs.modal; |
| 654 | + if (!this.$refs.modal) { |
| 655 | + logger.warn( |
| 656 | + 'Could not start the slideshow, the viewer this.$refs.modal is not mounted', |
| 657 | + ) |
| 658 | + return |
| 659 | + } |
| 660 | + this.$refs.modal.togglePlayPause() |
| 661 | +
|
| 662 | + if (this.playingVideo) { |
| 663 | + this.$refs.modal.slideshowTimeout?.pause() |
| 664 | + } |
| 665 | + }, |
| 666 | +
|
626 | 667 | /** |
627 | 668 | * Open the view and display the clicked file |
628 | 669 | * |
@@ -1035,6 +1076,8 @@ export default defineComponent({ |
1035 | 1076 | this.currentModal = null |
1036 | 1077 | this.fileList = [] |
1037 | 1078 | this.initiated = false |
| 1079 | + this.slideshowStarted = false |
| 1080 | + this.playingVideo = false |
1038 | 1081 | this.theme = null |
1039 | 1082 |
|
1040 | 1083 | // cancel requests |
|
0 commit comments