aboutsummaryrefslogtreecommitdiff
path: root/src/components/still-image
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2018-02-03 19:55:45 +0300
committerHenry Jameson <me@hjkos.com>2018-03-12 01:30:27 +0300
commit3257991f4196cb6c2c77b3f81ec9f1850e243211 (patch)
treed257c08c0fa7244fe01a5ca7fe0ed110e19f4b5d /src/components/still-image
parentb10787d23ca645932e89383ebb39402d1eb84700 (diff)
unfinished fetch() version that doesn't work
Diffstat (limited to 'src/components/still-image')
-rw-r--r--src/components/still-image/still-image.js21
-rw-r--r--src/components/still-image/still-image.vue5
2 files changed, 19 insertions, 7 deletions
diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js
index fa027bc4..e674b932 100644
--- a/src/components/still-image/still-image.js
+++ b/src/components/still-image/still-image.js
@@ -12,16 +12,27 @@ const StillImage = {
}
},
computed: {
- animated () {
- return this.mimetype === 'image/gif'
+ animated: {
+ get () {
+ // If mimetype is gif then it is certainly animated, if it's undefined - we don't know YET
+ return this.mimetype === 'image/gif' ? true : this.mimetype == null ? 'maybe' : false
+ },
+ set (val) {
+ this.mimetype = val
+ }
}
},
methods: {
- drawCanvas() {
+ onLoad () {
const canvas = this.$refs.canvas
if (!canvas) return
- const ctx = canvas.getContext('2d')
- ctx.drawImage(this.$refs.src, 1, 1, canvas.width, canvas.height)
+ canvas.getContext('2d').drawImage(this.$refs.src, 1, 1, canvas.width, canvas.height)
+ if (this.animated === 'maybe') {
+ fetch(this.src).then((data) => {
+ console.log(data)
+ this.animated = data.type
+ })
+ }
}
}
}
diff --git a/src/components/still-image/still-image.vue b/src/components/still-image/still-image.vue
index fa086e51..cc426fff 100644
--- a/src/components/still-image/still-image.vue
+++ b/src/components/still-image/still-image.vue
@@ -1,7 +1,7 @@
<template>
<div class='still-image' :class='{ animated: animated }' >
<canvas ref="canvas" v-if="animated"></canvas>
- <img ref="src" :src="src" :referrerpolicy="referrerpolicy" v-on:load="drawCanvas"/>
+ <img ref="src" :src="src" :referrerpolicy="referrerpolicy" v-on:load="onLoad"/>
</div>
</template>
@@ -31,9 +31,10 @@
position: absolute;
top: 5px;
left: 5px;
- background: rgba(255,255,255,.5);
+ background: rgba(127,127,127,.7);
display: block;
padding: 2px;
+ border-radius: 3px;
z-index: 2;
}
}