diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-16 22:46:18 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-16 22:46:18 +0900 |
| commit | 091923764d3083dda958ca1109c6c7a806414a4f (patch) | |
| tree | 3b6bcac7526853133745b52cc07a7e758057b03b /src/client/components | |
| parent | Resolve #5942 (diff) | |
| download | misskey-091923764d3083dda958ca1109c6c7a806414a4f.tar.gz misskey-091923764d3083dda958ca1109c6c7a806414a4f.tar.bz2 misskey-091923764d3083dda958ca1109c6c7a806414a4f.zip | |
Implement image dialog
Diffstat (limited to 'src/client/components')
| -rw-r--r-- | src/client/components/image-viewer.vue | 54 | ||||
| -rw-r--r-- | src/client/components/media-image.vue | 12 | ||||
| -rw-r--r-- | src/client/components/modal.vue | 9 |
3 files changed, 73 insertions, 2 deletions
diff --git a/src/client/components/image-viewer.vue b/src/client/components/image-viewer.vue new file mode 100644 index 0000000000..3359b600da --- /dev/null +++ b/src/client/components/image-viewer.vue @@ -0,0 +1,54 @@ +<template> +<x-modal ref="modal" @closed="() => { $emit('closed'); destroyDom(); }"> + <img class="xubzgfga" ref="img" :src="image.url" :alt="image.name" :title="image.name" @click="close" tabindex="-1"/> +</x-modal> +</template> + +<script lang="ts"> +import Vue from 'vue'; +import i18n from '../i18n'; +import XModal from './modal.vue'; + +export default Vue.extend({ + i18n, + + components: { + XModal, + }, + + props: { + image: { + type: Object, + required: true + }, + }, + + mounted() { + this.$nextTick(() => { + this.$refs.img.focus(); + }); + }, + + methods: { + close() { + this.$refs.modal.close(); + }, + } +}); +</script> + +<style lang="scss" scoped> +.xubzgfga { + position: fixed; + z-index: 2; + top: 0; + right: 0; + bottom: 0; + left: 0; + max-width: 100%; + max-height: 100%; + margin: auto; + cursor: zoom-out; + image-orientation: from-image; +} +</style> diff --git a/src/client/components/media-image.vue b/src/client/components/media-image.vue index 5ae167d490..3bb1bda5e2 100644 --- a/src/client/components/media-image.vue +++ b/src/client/components/media-image.vue @@ -20,6 +20,7 @@ import Vue from 'vue'; import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; import i18n from '../i18n'; import { getStaticImageUrl } from '../scripts/get-static-image-url'; +import ImageViewer from './image-viewer.vue'; export default Vue.extend({ i18n, @@ -60,7 +61,16 @@ export default Vue.extend({ }, methods: { onClick() { - window.open(this.image.url, '_blank'); + if (this.$store.state.device.imageNewTab) { + window.open(this.image.url, '_blank'); + } else { + const viewer = this.$root.new(ImageViewer, { + image: this.image + }); + this.$once('hook:beforeDestroy', () => { + viewer.close(); + }); + } } } }); diff --git a/src/client/components/modal.vue b/src/client/components/modal.vue index a48c7154ee..1a9d98a8cc 100644 --- a/src/client/components/modal.vue +++ b/src/client/components/modal.vue @@ -1,5 +1,5 @@ <template> -<div class="mk-modal"> +<div class="mk-modal" v-hotkey.global="keymap"> <transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear> <div class="bg" ref="bg" v-if="show" @click="close()"></div> </transition> @@ -20,6 +20,13 @@ export default Vue.extend({ show: true, }; }, + computed: { + keymap(): any { + return { + 'esc': this.close, + }; + }, + }, methods: { close() { this.show = false; |