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; flex-grow: 1;
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
max-width: 32rem; max-width: calc(100% - 2rem);
width: 32rem;
} }

View file

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

View file

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

View file

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

View file

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