1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-23 02:58:30 +09:00
misskey/src/client/components/particle.vue

109 lines
2.5 KiB
Vue
Raw Normal View History

2020-02-22 01:20:58 +09:00
<template>
2020-02-22 02:26:01 +09:00
<div class="vswabwbm" :style="{ top: `${y - 64}px`, left: `${x - 64}px` }" :class="{ active }">
<svg width="128" height="128" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
<circle fill="none" cx="64" cy="64">
<animate attributeName="r"
2020-02-22 03:51:31 +09:00
begin="0s" dur="0.5s"
2020-02-22 02:26:01 +09:00
values="4; 32"
calcMode="spline"
keyTimes="0; 1"
keySplines="0.165, 0.84, 0.44, 1"
repeatCount="1" />
<animate attributeName="stroke-width"
2020-02-22 03:51:31 +09:00
begin="0s" dur="0.5s"
2020-02-22 02:26:01 +09:00
values="16; 0"
calcMode="spline"
keyTimes="0; 1"
keySplines="0.3, 0.61, 0.355, 1"
repeatCount="1" />
</circle>
<g fill="none" fill-rule="evenodd">
<circle v-for="(particle, i) in particles" :key="i" :fill="particle.color">
<animate attributeName="r"
2020-02-22 03:51:31 +09:00
begin="0s" dur="0.8s"
2020-02-22 02:26:01 +09:00
:values="`${particle.size}; 0`"
calcMode="spline"
keyTimes="0; 1"
keySplines="0.165, 0.84, 0.44, 1"
repeatCount="1" />
<animate attributeName="cx"
2020-02-22 03:51:31 +09:00
begin="0s" dur="0.8s"
2020-02-22 02:26:01 +09:00
:values="`${particle.xA}; ${particle.xB}`"
calcMode="spline"
keyTimes="0; 1"
keySplines="0.3, 0.61, 0.355, 1"
repeatCount="1" />
<animate attributeName="cy"
2020-02-22 03:51:31 +09:00
begin="0s" dur="0.8s"
2020-02-22 02:26:01 +09:00
:values="`${particle.yA}; ${particle.yB}`"
calcMode="spline"
keyTimes="0; 1"
keySplines="0.3, 0.61, 0.355, 1"
repeatCount="1" />
</circle>
</g>
</svg>
</div>
2020-02-22 01:20:58 +09:00
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
x: {
type: Number,
required: true
},
y: {
type: Number,
required: true
}
},
data() {
2020-02-22 02:26:01 +09:00
const particles = [];
const origin = 64;
2020-02-22 02:30:41 +09:00
const colors = ['#FF1493', '#00FFFF', '#FFE202'];
2020-02-22 02:26:01 +09:00
for (let i = 0; i < 12; i++) {
const angle = Math.random() * (Math.PI * 2);
const pos = Math.random() * 16;
const velocity = 16 + (Math.random() * 48);
particles.push({
size: 4 + (Math.random() * 8),
xA: origin + (Math.sin(angle) * pos),
yA: origin + (Math.cos(angle) * pos),
xB: origin + (Math.sin(angle) * (pos + velocity)),
yB: origin + (Math.cos(angle) * (pos + velocity)),
color: colors[Math.floor(Math.random() * colors.length)]
});
2020-02-22 01:20:58 +09:00
}
2020-02-22 02:26:01 +09:00
return {
particles
};
2020-02-22 01:20:58 +09:00
},
mounted() {
setTimeout(() => {
this.destroyDom();
2020-02-22 02:26:01 +09:00
}, 1100);
2020-02-22 01:20:58 +09:00
}
});
</script>
<style lang="scss" scoped>
.vswabwbm {
pointer-events: none;
position: fixed;
z-index: 1000000;
2020-02-22 02:26:01 +09:00
width: 128px;
height: 128px;
2020-02-22 01:20:58 +09:00
2020-02-22 02:26:01 +09:00
> svg {
> circle {
stroke: var(--accent);
}
2020-02-22 01:20:58 +09:00
}
}
</style>