egirlskey/packages/frontend/src/components/MkUrlPreviewPopup.vue
syuilo 93d3cc310d 🎨
2022-12-30 13:52:40 +09:00

45 lines
1.1 KiB
Vue

<template>
<div class="fgmtyycl" :style="{ zIndex, top: top + 'px', left: left + 'px' }">
<Transition :name="$store.state.animation ? '_transition_zoom' : ''" @after-leave="emit('closed')">
<MkUrlPreview v-if="showing" class="_popup _shadow" :url="url"/>
</Transition>
</div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import MkUrlPreview from '@/components/MkUrlPreview.vue';
import * as os from '@/os';
const props = defineProps<{
showing: boolean;
url: string;
source: HTMLElement;
}>();
const emit = defineEmits<{
(ev: 'closed'): void;
}>();
const zIndex = os.claimZIndex('middle');
let top = $ref(0);
let left = $ref(0);
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;
top = y;
left = x;
});
</script>
<style lang="scss" scoped>
.fgmtyycl {
position: absolute;
width: 500px;
max-width: calc(90vw - 12px);
pointer-events: none;
}
</style>