2020-02-09 18:59:00 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div
|
|
|
|
class="fgmtyycl"
|
|
|
|
:style="{ zIndex, top: top + 'px', left: left + 'px' }"
|
|
|
|
>
|
|
|
|
<transition
|
2023-10-17 03:57:20 +02:00
|
|
|
:name="defaultStore.state.animation ? 'zoom' : ''"
|
2023-04-08 02:01:42 +02:00
|
|
|
@after-leave="emit('closed')"
|
|
|
|
>
|
|
|
|
<MkUrlPreview v-if="showing" class="_popup _shadow" :url="url" />
|
|
|
|
</transition>
|
|
|
|
</div>
|
2020-02-09 18:59:00 +01:00
|
|
|
</template>
|
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
<script lang="ts" setup>
|
2023-08-12 02:44:46 +02:00
|
|
|
import { onMounted, ref } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import MkUrlPreview from "@/components/MkUrlPreview.vue";
|
|
|
|
import * as os from "@/os";
|
2023-10-17 03:57:20 +02:00
|
|
|
import { defaultStore } from "@/store";
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
showing: boolean;
|
|
|
|
url: string;
|
|
|
|
source: HTMLElement;
|
|
|
|
}>();
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "closed"): void;
|
2022-09-05 11:37:41 +02:00
|
|
|
}>();
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const zIndex = os.claimZIndex("middle");
|
2023-09-02 01:27:33 +02:00
|
|
|
const top = ref(0);
|
|
|
|
const left = ref(0);
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
onMounted(() => {
|
|
|
|
const rect = props.source.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x =
|
|
|
|
Math.max(rect.left + props.source.offsetWidth / 2 - 300 / 2, 6) +
|
2024-04-08 10:31:33 +02:00
|
|
|
window.scrollX;
|
|
|
|
const y = rect.top + props.source.offsetHeight + window.scrollY;
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
top.value = y;
|
|
|
|
left.value = x;
|
2020-02-09 18:59:00 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.fgmtyycl {
|
|
|
|
position: absolute;
|
2020-02-09 19:13:24 +01:00
|
|
|
width: 500px;
|
2020-04-13 17:00:52 +02:00
|
|
|
max-width: calc(90vw - 12px);
|
2020-02-09 19:13:24 +01:00
|
|
|
pointer-events: none;
|
2020-02-09 18:59:00 +01:00
|
|
|
}
|
|
|
|
</style>
|