2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-12 03:37:45 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-02-09 18:59:00 +01:00
|
|
|
<template>
|
2023-05-14 03:21:56 +02:00
|
|
|
<div :class="$style.root" :style="{ zIndex, top: top + 'px', left: left + 'px' }">
|
2023-05-19 06:58:09 +02:00
|
|
|
<Transition :name="defaultStore.state.animation ? '_transition_zoom' : ''" @afterLeave="emit('closed')">
|
2023-07-21 02:57:21 +02:00
|
|
|
<MkUrlPreview v-if="showing" class="_popup _shadow" :url="url" :showActions="false"/>
|
2022-12-30 05:37:14 +01:00
|
|
|
</Transition>
|
2020-02-09 18:59:00 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { onMounted, ref } from 'vue';
|
2022-08-30 17:24:33 +02:00
|
|
|
import MkUrlPreview from '@/components/MkUrlPreview.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
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<{
|
|
|
|
(ev: 'closed'): void;
|
|
|
|
}>();
|
2020-02-09 18:59:00 +01:00
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
const zIndex = os.claimZIndex('middle');
|
2023-12-07 06:42:09 +01: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();
|
|
|
|
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-09 18:59:00 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
top.value = y;
|
|
|
|
left.value = x;
|
2020-02-09 18:59:00 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-05-14 03:21:56 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-09 18:59:00 +01:00
|
|
|
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>
|