2020-02-10 02:59:00 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<div
|
|
|
|
class="fgmtyycl"
|
|
|
|
:style="{ zIndex, top: top + 'px', left: left + 'px' }"
|
|
|
|
>
|
|
|
|
<transition
|
|
|
|
:name="$store.state.animation ? 'zoom' : ''"
|
|
|
|
@after-leave="emit('closed')"
|
|
|
|
>
|
|
|
|
<MkUrlPreview v-if="showing" class="_popup _shadow" :url="url" />
|
|
|
|
</transition>
|
|
|
|
</div>
|
2020-02-10 02:59:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-09-05 18:37:41 +09:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 09:01:42 +09:00
|
|
|
import { onMounted } from "vue";
|
|
|
|
import MkUrlPreview from "@/components/MkUrlPreview.vue";
|
|
|
|
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<{
|
2023-04-08 09:01:42 +09:00
|
|
|
(ev: "closed"): void;
|
2022-09-05 18:37:41 +09:00
|
|
|
}>();
|
2020-02-10 02:59:00 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const zIndex = os.claimZIndex("middle");
|
2022-09-05 18:37:41 +09:00
|
|
|
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();
|
2023-04-08 09:01:42 +09:00
|
|
|
const x =
|
|
|
|
Math.max(rect.left + props.source.offsetWidth / 2 - 300 / 2, 6) +
|
|
|
|
window.pageXOffset;
|
2022-09-05 18:37:41 +09:00
|
|
|
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>
|
|
|
|
.fgmtyycl {
|
|
|
|
position: absolute;
|
2020-02-10 03:13:24 +09:00
|
|
|
width: 500px;
|
2020-04-14 00:00:52 +09:00
|
|
|
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>
|