Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/client/src/components/emote.vue

88 lines
2.2 KiB
Vue
Raw Normal View History

2020-01-24 04:23:26 +13:00
<template>
2020-02-12 07:10:24 +13:00
<div ref="emote" @click.stop.prevent="run" class="emote-container">
2020-01-24 05:54:32 +13:00
<div :class="classes" />
<div :class="classes" />
<div :class="classes" />
<div :class="classes" />
<div :class="classes" />
<div :class="classes" />
<div :class="classes" />
2020-01-24 04:23:26 +13:00
</div>
</template>
<style lang="scss" scoped>
2020-02-12 07:10:24 +13:00
.emote-container {
width: 25%;
height: 10%;
2020-01-24 04:23:26 +13:00
position: absolute;
bottom: 0;
right: 0;
2020-02-12 07:10:24 +13:00
.emote {
2020-01-24 04:23:26 +13:00
position: absolute;
2020-02-12 07:10:24 +13:00
width: 100px;
height: 100%;
2020-01-24 04:23:26 +13:00
color: #fff;
2020-02-12 07:10:24 +13:00
transform: scale(0.7);
2020-01-24 04:23:26 +13:00
text-align: center;
2020-01-24 05:54:32 +13:00
background-size: contain;
2020-01-24 04:23:26 +13:00
}
}
</style>
<script lang="ts">
import { Component, Ref, Vue, Prop } from 'vue-property-decorator'
@Component({ name: 'neko-emote' })
export default class extends Vue {
@Prop({
required: true,
})
id!: string
@Ref('emote') container!: HTMLElement
get emote() {
return this.$accessor.chat.emotes[this.id]
}
private classes: string[] = []
mounted() {
2020-02-12 07:10:24 +13:00
const range = 50
2020-01-24 04:23:26 +13:00
let count = 0
let finish: Array<Promise<any>> = []
2020-02-12 07:10:24 +13:00
this.classes = ['emote', this.emote.type]
2020-01-24 04:23:26 +13:00
for (let child of this.container.children) {
const ele = child as HTMLElement
2020-02-12 07:10:24 +13:00
ele.style['left'] = `${count % 2 ? this.$anime.random(0, range) : this.$anime.random(-range, 0)}%`
2020-01-24 04:23:26 +13:00
ele.style['opacity'] = `0`
const animation = this.$anime({
targets: child,
keyframes: [
2020-02-12 07:10:24 +13:00
{ left: `${count % 2 ? this.$anime.random(0, range) : this.$anime.random(-range, 0)}%`, opacity: 1 },
{ left: `${count % 2 ? this.$anime.random(-range, 0) : this.$anime.random(0, range)}%`, opacity: 0.5 },
{ left: `${count % 2 ? this.$anime.random(0, range) : this.$anime.random(-range, 0)}%`, opacity: 0 },
2020-01-24 04:23:26 +13:00
],
elasticity: 600,
rotate: this.$anime.random(-35, 35),
2020-02-12 07:10:24 +13:00
top: `${this.$anime.random(-200, -600)}%`,
2020-01-24 04:23:26 +13:00
duration: this.$anime.random(1000, 2000),
easing: 'easeInOutQuad',
})
count++
finish.push(animation.finished)
}
Promise.all(finish).then(() => {
this.$emit('done', this.id)
this.$accessor.chat.delEmote(this.id)
})
}
}
</script>