feat(capture preview): Rescale on screen resize

This commit is contained in:
Tixie 2019-03-11 01:21:38 +01:00
parent 69e31c3304
commit 7dbdc405a2
5 changed files with 23 additions and 4 deletions

View file

@ -9,5 +9,6 @@
flex-grow: 1;
margin-right: auto;
margin-left: auto;
max-width: 32rem;
max-width: calc(100% - 2rem);
width: 32rem;
}

View file

@ -6,6 +6,7 @@
display: flex;
flex-direction: column;
flex-grow: 1;
max-width: 100%;
}
/* Progress bar

View file

@ -6,6 +6,7 @@
display: flex;
flex-direction: column;
flex-grow: 1;
max-width: 100%;
}
.download-btn,

View file

@ -24,6 +24,12 @@ import { mapState } from 'vuex'
export default {
name: 'capture',
data () {
return {
loadListener: null,
resizeListener: null
}
},
components: {
captureOptions,
captureProgress,
@ -84,11 +90,21 @@ export default {
},
mounted: function () {
this.$refs.preview.srcObject = this.mediaStream
this.getpreviewcontainerSquare()
this.$refs.preview.addEventListener('resize', ev => {
// On load
this.loadListener = this.$refs.preview.addEventListener('resize', () => {
this.applyScaling()
}, false)
// On window resize
this.resizeListener = window.addEventListener('resize', () => {
this.getpreviewcontainerSquare()
this.applyScaling()
}, false)
},
destroyed: function () {
this.loadListener = null
this.resizeListener = null
}
}
</script>

View file

@ -5,7 +5,7 @@
<button class="options__btn" @click="back"> back</button>
</div>
<div class="preview">
<div class="preview" ref="previewcontainer">
<img class="preview-visualImg" :src="downloading.objectUrl" alt="">
</div>