Skip to content

Commit 300cccd

Browse files
authored
Merge pull request #20 from nextcloud/enhancement/modal/resize
Recalculate size on window resize
2 parents 7227a37 + c9e397b commit 300cccd

6 files changed

Lines changed: 47 additions & 10 deletions

File tree

apps/viewer/apps/viewer/package-lock.json

Lines changed: 17 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/viewer/apps/viewer/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
},
3636
"dependencies": {
3737
"axios": "^0.18.0",
38+
"debounce": "^1.2.0",
3839
"mime-types": "^2.1.22",
3940
"nextcloud-server": "^0.15.9",
40-
"nextcloud-vue": "^0.8.0",
41+
"nextcloud-vue": "^0.9.0",
4142
"vue": "^2.6.8",
4243
"vue-async-computed": "^3.6.1"
4344
},

apps/viewer/apps/viewer/src/components/Images.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import mime from 'Mixins/Mime'
3535
import axios from 'axios'
3636
import Vue from 'vue'
37+
import debounce from 'debounce'
3738
import AsyncComputed from 'vue-async-computed'
3839
3940
Vue.use(AsyncComputed)
@@ -51,7 +52,13 @@ export default {
5152
return this.getBase64FromImage()
5253
}
5354
},
55+
mounted() {
56+
window.addEventListener('resize', debounce(() => {
57+
this.updateImgSize()
58+
}, 100))
59+
},
5460
methods: {
61+
// Updates the dimensions of the modal
5562
updateImgSize() {
5663
const naturalHeight = this.$el.naturalHeight
5764
const naturalWidth = this.$el.naturalWidth
@@ -64,6 +71,7 @@ export default {
6471
6572
this.doneLoading()
6673
},
74+
6775
/**
6876
* Manually retrieve the path and return its base64
6977
*

apps/viewer/apps/viewer/src/components/Videos.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
</template>
4444

4545
<script>
46+
import debounce from 'debounce'
4647
import mime from 'Mixins/Mime'
4748
4849
export default {
@@ -67,18 +68,28 @@ export default {
6768
}
6869
}
6970
},
71+
mounted() {
72+
window.addEventListener('resize', debounce(() => {
73+
this.updateVideoSize()
74+
}, 100))
75+
},
7076
methods: {
77+
// Updates the dimensions of the modal
7178
updateVideoSize() {
7279
const videoHeight = this.$el.videoHeight
7380
const videoWidth = this.$el.videoWidth
7481
this.updateHeightWidth(videoHeight, videoWidth)
7582
},
83+
84+
// Show/hide video controls
7685
showControls() {
7786
this.visibleControls = true
7887
},
7988
hideControls() {
8089
this.visibleControls = false
8190
},
91+
92+
// Toggle play/pause
8293
playPause() {
8394
if (this.$el.paused) {
8495
this.$el.play()

apps/viewer/apps/viewer/src/mixins/Mime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default {
6767
const modalContainer = this.$parent.$el.querySelector('#modal-wrapper')
6868
if (modalContainer) {
6969
// ! modal container have maxHeight:80% AND maxWidth: 900px
70-
const parentHeight = Math.round(modalContainer.clientHeight * 0.8)
70+
const parentHeight = Math.round(modalContainer.clientHeight * 0.8) - 50 // minus header
7171
const parentWidth = modalContainer.clientWidth > 900
7272
? 900
7373
: modalContainer.clientWidth

apps/viewer/apps/viewer/src/views/Viewer.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
:key="previousFile.path"
4242
:mime="previousFile.mime"
4343
:path="previousFile.path"
44-
class="hidden-visually"
44+
class="hidden-visually file-view"
4545
@error="previousFailed" />
4646
<error
4747
v-else
@@ -56,6 +56,7 @@
5656
:mime="currentFile.mime"
5757
:path="currentFile.path"
5858
:active="true"
59+
class="file-view"
5960
@loaded="doneLoading"
6061
@error="currentFailed" />
6162
<error
@@ -70,7 +71,7 @@
7071
:key="nextFile.path"
7172
:mime="nextFile.mime"
7273
:path="nextFile.path"
73-
class="hidden-visually"
74+
class="hidden-visually file-view"
7475
@error="nextFailed" />
7576
<error
7677
v-else
@@ -439,4 +440,9 @@ export default {
439440
.icon-share-white-forced {
440441
background-image: url('~Assets/share-white.svg');
441442
}
443+
444+
.file-view {
445+
transition: height 100ms ease,
446+
width 100ms ease;
447+
}
442448
</style>

0 commit comments

Comments
 (0)