1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-14 22:59:31 +09:00
MisskeyIO/packages/frontend/src/components/MkUrlPreviewPopup.vue

46 lines
1.1 KiB
Vue
Raw Normal View History

2020-02-10 02:59:00 +09:00
<template>
<div class="fgmtyycl" :style="{ zIndex, top: top + 'px', left: left + 'px' }">
2022-12-30 13:52:40 +09:00
<Transition :name="$store.state.animation ? '_transition_zoom' : ''" @after-leave="emit('closed')">
2021-11-19 19:36:12 +09:00
<MkUrlPreview v-if="showing" class="_popup _shadow" :url="url"/>
2022-12-30 13:37:14 +09:00
</Transition>
2020-02-10 02:59:00 +09:00
</div>
</template>
2022-09-05 18:37:41 +09:00
<script lang="ts" setup>
import { onMounted } from 'vue';
import MkUrlPreview from '@/components/MkUrlPreview.vue';
2021-11-12 02:02:25 +09:00
import * as os from '@/os';
2020-02-10 02:59:00 +09:00
2022-09-05 18:37:41 +09:00
const props = defineProps<{
showing: boolean;
url: string;
source: HTMLElement;
}>();
2020-02-10 02:59:00 +09:00
2022-09-05 18:37:41 +09:00
const emit = defineEmits<{
(ev: 'closed'): void;
}>();
2020-02-10 02:59:00 +09:00
2022-09-05 18:37:41 +09:00
const zIndex = os.claimZIndex('middle');
let top = $ref(0);
let left = $ref(0);
2020-02-10 02:59:00 +09:00
2022-09-05 18:37:41 +09:00
onMounted(() => {
const rect = props.source.getBoundingClientRect();
const x = Math.max((rect.left + (props.source.offsetWidth / 2)) - (300 / 2), 6) + window.pageXOffset;
const y = rect.top + props.source.offsetHeight + window.pageYOffset;
2020-02-10 02:59:00 +09:00
2022-09-05 18:37:41 +09:00
top = y;
left = x;
2020-02-10 02:59:00 +09:00
});
</script>
<style lang="scss" scoped>
2020-02-10 02:59:00 +09:00
.fgmtyycl {
position: absolute;
2020-02-10 03:13:24 +09:00
width: 500px;
max-width: calc(90vw - 12px);
2020-02-10 03:13:24 +09:00
pointer-events: none;
2020-02-10 02:59:00 +09:00
}
</style>