1
0
forked from mirror/misskey
misskey/packages/frontend/src/components/MkReactionEffect.vue

76 lines
1.4 KiB
Vue
Raw Normal View History

<!--
2024-02-12 11:37:45 +09:00
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
2023-01-01 12:28:30 +09:00
<template>
<div :class="$style.root" :style="{ zIndex, top: `${y - 64}px`, left: `${x - 64}px` }">
2023-01-14 17:23:49 +09:00
<span :class="[$style.text, { [$style.up]: up }]">
2023-01-08 14:22:04 +09:00
<MkReactionIcon class="icon" :reaction="reaction"/>
2023-01-07 17:37:30 +09:00
</span>
2023-01-01 12:28:30 +09:00
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
2023-09-19 16:37:43 +09:00
import * as os from '@/os.js';
2023-01-08 14:22:04 +09:00
import MkReactionIcon from '@/components/MkReactionIcon.vue';
2023-01-01 12:28:30 +09:00
const props = withDefaults(defineProps<{
2023-01-07 17:37:30 +09:00
reaction: string;
2023-01-01 12:28:30 +09:00
x: number;
y: number;
}>(), {
});
const emit = defineEmits<{
(ev: 'end'): void;
}>();
const up = ref(false);
2023-01-08 17:38:33 +09:00
const zIndex = os.claimZIndex('middle');
2023-01-07 17:37:30 +09:00
const angle = (90 - (Math.random() * 180)) + 'deg';
2023-01-01 12:28:30 +09:00
onMounted(() => {
window.setTimeout(() => {
up.value = true;
2023-01-01 12:28:30 +09:00
}, 10);
window.setTimeout(() => {
emit('end');
}, 1100);
});
</script>
<style lang="scss" module>
.root {
pointer-events: none;
position: fixed;
width: 128px;
height: 128px;
2023-01-14 17:23:49 +09:00
}
2023-01-01 12:28:30 +09:00
2023-01-14 17:23:49 +09:00
.text {
display: block;
height: 1em;
text-align: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
color: var(--accent);
font-size: 18px;
font-weight: bold;
transform: translateY(-30px);
transition: transform 1s cubic-bezier(0,.5,0,1), opacity 1s cubic-bezier(.5,0,1,.5);
will-change: opacity, transform;
2023-01-01 12:28:30 +09:00
2023-01-14 17:23:49 +09:00
&.up {
opacity: 0;
transform: translateY(-50px) rotateZ(v-bind(angle));
2023-01-01 12:28:30 +09:00
}
}
</style>