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

113 lines
2.8 KiB
Vue
Raw Normal View History

2020-01-24 04:23:26 +13:00
<template>
<div ref="emote" @click.stop.prevent="run" class="emote">
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>
.emote {
width: 150px;
height: 30px;
position: absolute;
bottom: 0;
right: 0;
2020-01-24 05:54:32 +13:00
div {
2020-01-24 04:23:26 +13:00
position: absolute;
width: 30px;
height: 30px;
color: #fff;
font-size: 30px;
line-height: 30px;
text-align: center;
2020-01-24 05:54:32 +13:00
background-size: contain;
2020-01-24 04:23:26 +13:00
2020-01-24 05:54:32 +13:00
&.celebrate {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/celebrate.png');
2020-01-24 04:23:26 +13:00
}
2020-01-24 05:54:32 +13:00
&.clap {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/clap.png');
2020-01-24 04:23:26 +13:00
}
2020-01-24 05:54:32 +13:00
&.exclam {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/exclam.png');
2020-01-24 04:23:26 +13:00
}
2020-01-24 05:54:32 +13:00
&.heart {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/heart.png');
2020-01-24 05:54:32 +13:00
}
&.laughing {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/laughing.png');
2020-01-24 05:54:32 +13:00
}
&.sleep {
2020-02-02 09:35:48 +13:00
background-image: url('../assets/images/emote/sleep.png');
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() {
const range = 90
let count = 0
let finish: Array<Promise<any>> = []
2020-01-24 05:54:32 +13:00
this.classes = [this.emote.type]
2020-01-24 04:23:26 +13:00
for (let child of this.container.children) {
const ele = child as HTMLElement
ele.style['left'] = `${count % 2 ? this.$anime.random(0, range) : this.$anime.random(-range, 0)}px`
ele.style['opacity'] = `0`
const animation = this.$anime({
targets: child,
keyframes: [
{ 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 },
],
elasticity: 600,
rotate: this.$anime.random(-35, 35),
top: this.$anime.random(-100, -250),
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>