diff options
| author | Henry Jameson <me@hjkos.com> | 2018-01-29 10:47:26 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2018-03-12 01:30:27 +0300 |
| commit | b10787d23ca645932e89383ebb39402d1eb84700 (patch) | |
| tree | d184ec36b908a707ebf6e4726b2c02d351044605 /src/components/still-image | |
| parent | cd3bf461dba72ddb04c4b1c3a4b736009b968cbe (diff) | |
first ver
Diffstat (limited to 'src/components/still-image')
| -rw-r--r-- | src/components/still-image/still-image.js | 29 | ||||
| -rw-r--r-- | src/components/still-image/still-image.vue | 51 |
2 files changed, 80 insertions, 0 deletions
diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js new file mode 100644 index 00000000..fa027bc4 --- /dev/null +++ b/src/components/still-image/still-image.js @@ -0,0 +1,29 @@ +import fileTypeService from '../../services/file_type/file_type.service.js' + +const StillImage = { + props: [ + 'src', + 'referrerpolicy', + 'mimetype' + ], + data () { + return { + hideNsfwLocal: this.$store.state.config.hideNsfw, + } + }, + computed: { + animated () { + return this.mimetype === 'image/gif' + } + }, + methods: { + drawCanvas() { + const canvas = this.$refs.canvas + if (!canvas) return + const ctx = canvas.getContext('2d') + ctx.drawImage(this.$refs.src, 1, 1, canvas.width, canvas.height) + } + } +} + +export default StillImage diff --git a/src/components/still-image/still-image.vue b/src/components/still-image/still-image.vue new file mode 100644 index 00000000..fa086e51 --- /dev/null +++ b/src/components/still-image/still-image.vue @@ -0,0 +1,51 @@ +<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"/> + </div> +</template> + +<script src="./still-image.js"></script> + +<style lang="scss"> +@import '../../_variables.scss'; +.still-image { + position: relative; + + &:hover canvas { + display: none; + } + + &.animated { + &:hover::before, + img { + visibility: hidden + } + + &:hover img { + visibility: visible + } + + &::before { + content: 'gif'; + position: absolute; + top: 5px; + left: 5px; + background: rgba(255,255,255,.5); + display: block; + padding: 2px; + z-index: 2; + } + } + + canvas { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 100%; + height: 100%; + } +} +</style> |
