add download gif

This commit is contained in:
wryk 2019-03-10 05:58:19 +01:00
parent cbe8785f99
commit b28aabb5ec
4 changed files with 5 additions and 4 deletions

View file

@ -7,7 +7,6 @@ const FRAMES_PER_SECOND = 10
const WIDTH = 200
const HEIGHT = WIDTH
export function capture (commit, mediaStream, duration) {
return new Promise((resolve, reject) => {
const video = document.createElement('video')

View file

@ -5,7 +5,6 @@ import {
} from 'gif-writer'
onmessage = (event) => {
console.log(event.data)
const { imageDataList, imageWidth, imageHeight, paletteSize, delayTime } = event.data
console.log('Write GIF')

View file

@ -22,7 +22,8 @@ export default new Vuex.Store({
},
downloading: {
status: false,
dataUrl: null
dataUrl: null,
timestamp: null
}
},
mutations: {
@ -54,10 +55,12 @@ export default new Vuex.Store({
startDownloading (store, dataUrl) {
store.downloading.status = true
store.downloading.dataUrl = dataUrl
store.downloading.timestamp = Date.now()
},
stopDownloading (store) {
store.downloading.status = false
store.downloading.dataUrl = null
store.downloading.timestamp = null
}
},
actions: {

View file

@ -9,7 +9,7 @@
<img class="preview-visual" :src="downloading.dataUrl" alt="">
</div>
<button class="download-btn btn btn--primary w100">Download GIF</button>
<a class="download-btn btn btn--primary w100" :href="downloading.dataUrl" :download="`souvenir${downloading.timestamp}.gif`">Download GIF</a>
</div>
</template>