feat: Add fake encoding state

This commit is contained in:
Tixie 2019-03-10 00:28:47 +01:00
parent 475d12c52f
commit a92d7f8149
6 changed files with 79 additions and 6 deletions

View file

@ -0,0 +1,18 @@
/* ----------------------------------------------------------- */
/* == Encoding overlay */
/* ----------------------------------------------------------- */
.encoding {
position: fixed;
top: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .7);
color: #fff;
text-align: center;
font-size: 2.4rem;
}

View file

@ -32,6 +32,7 @@
@import "4-modules/preview.css"; @import "4-modules/preview.css";
@import "4-modules/progress-bar.css"; @import "4-modules/progress-bar.css";
@import "4-modules/encoding.css";
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* == screens */ /* == screens */

View file

@ -1,11 +1,11 @@
<template lang="html"> <template lang="html">
<div class="capture-options"> <div class="capture-options">
<select class="capture-options__select" v-model="timer.selected" @change="updateTimer(timer.selected)"> <select class="capture-options__select" v-model="timer.selected" @change="updateTimer(timer.selected)" :disabled="encoding.status">
<option v-for="time in timer.list" :key="time" :value="time"> <option v-for="time in timer.list" :key="time" :value="time">
{{ timeLabel(time) }} {{ timeLabel(time) }}
</option> </option>
</select> </select>
<button class="capture-options__switch" @click="back"><icon-switch/>switch</button> <button class="capture-options__switch" @click="back" :disabled="encoding.status"><icon-switch/>switch</button>
</div> </div>
</template> </template>
@ -21,7 +21,8 @@ export default {
}, },
computed: { computed: {
...mapState([ ...mapState([
'timer' 'timer',
'encoding'
]) ])
}, },
methods: { methods: {

View file

@ -0,0 +1,38 @@
<template>
<div class="encoding">
Encoding {{ ellipsis }}
</div>
</template>
<script>
export default {
name: 'encodingOverlay',
data () {
return {
ellipsis: '',
interval: null
}
},
methods: {
makeLoading () {
// Dot loading
this.interval = setInterval(() => {
if (this.ellipsis.length < 3) {
this.ellipsis += '.'
} else {
this.ellipsis = ''
}
}, 200)
}
},
mounted: function () {
this.makeLoading()
window.setTimeout(() => {
this.$store.commit('stopEncoding')
}, 2000)
},
destroyed: function () {
window.clearTimeout(this.interval)
}
}
</script>

View file

@ -13,6 +13,9 @@ export default new Vuex.Store({
capturing: { capturing: {
status: false, status: false,
state: 0 state: 0
},
encoding: {
status: false
} }
}, },
mutations: { mutations: {
@ -30,6 +33,12 @@ export default new Vuex.Store({
}, },
updateCaptureState (store, percent) { updateCaptureState (store, percent) {
store.capturing.state = percent store.capturing.state = percent
},
startEncoding (store) {
store.encoding.status = true
},
stopEncoding (store) {
store.encoding.status = false
} }
}, },
actions: { actions: {

View file

@ -11,12 +11,14 @@
<button class="capture-btn" :class="{ 'capture-btn--capturing': capturing.status }" @click="startCapture">Capture</button> <button class="capture-btn" :class="{ 'capture-btn--capturing': capturing.status }" @click="startCapture">Capture</button>
<encoding-overlay v-if="encoding.status"/>
</div> </div>
</template> </template>
<script> <script>
import captureOptions from '@/components/capture-options' import captureOptions from '@/components/capture-options'
import captureProgress from '@/components/capture-progress' import captureProgress from '@/components/capture-progress'
import encodingOverlay from '@/components/encoding'
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -24,12 +26,14 @@ export default {
name: 'capture', name: 'capture',
components: { components: {
captureOptions, captureOptions,
captureProgress captureProgress,
encodingOverlay
}, },
computed: { computed: {
...mapState([ ...mapState([
'capturing', 'capturing',
'timer' 'timer',
'encoding'
]) ])
}, },
methods: { methods: {
@ -45,6 +49,8 @@ export default {
} else { } else {
window.clearInterval(fakeProgress) window.clearInterval(fakeProgress)
this.$store.commit('stopCapture') this.$store.commit('stopCapture')
this.$store.commit('updateCaptureState', 0)
this.$store.commit('startEncoding')
} }
}, interval) }, interval)
} }