tweak 7da4019
This commit is contained in:
parent
5d396a7c1e
commit
5c2097c2e1
|
@ -5,7 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
<template>
|
||||
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe }]" :to="url" :style="{ background: bgCss }">
|
||||
<img :class="$style.icon" :src="avatarUrl" alt="">
|
||||
<img
|
||||
:class="$style.icon"
|
||||
:src="avatarUrl"
|
||||
alt=""
|
||||
@mouseover="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = true : ''"
|
||||
@mouseout="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = false : ''"
|
||||
@touchstart="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = true : ''"
|
||||
@touchend="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = false : ''"
|
||||
>
|
||||
<span>
|
||||
<span>@{{ username }}</span>
|
||||
<span v-if="(host != localHost) || defaultStore.state.showFullAcct" :class="$style.host">@{{ toUnicode(host) }}</span>
|
||||
|
@ -15,12 +23,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { toUnicode } from 'punycode';
|
||||
import { computed } from 'vue';
|
||||
import { computed, onMounted, onUnmounted } from 'vue';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import { host as localHost } from '@/config.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
import { getStaticImageUrl } from '@/scripts/media-proxy.js';
|
||||
import MkImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
username: string;
|
||||
|
@ -39,10 +48,35 @@ const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue
|
|||
bg.setAlpha(0.1);
|
||||
const bgCss = bg.toRgbString();
|
||||
|
||||
const avatarUrl = computed(() => defaultStore.state.disableShowingAnimatedImages
|
||||
let playAnimation = $ref(true);
|
||||
if (defaultStore.state.showingAnimatedImages === 'interaction') playAnimation = false;
|
||||
let playAnimationTimer = setTimeout(() => playAnimation = false, 5000);
|
||||
const avatarUrl = $computed(() => defaultStore.state.disableShowingAnimatedImages || (['interaction', 'inactive'].includes(<string>defaultStore.state.showingAnimatedImages) && !playAnimation)
|
||||
? getStaticImageUrl(`/avatar/@${props.username}@${props.host}`)
|
||||
: `/avatar/@${props.username}@${props.host}`,
|
||||
);
|
||||
|
||||
function resetTimer() {
|
||||
playAnimation = true;
|
||||
clearTimeout(playAnimationTimer);
|
||||
playAnimationTimer = setTimeout(() => playAnimation = false, 5000);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (defaultStore.state.showingAnimatedImages === 'inactive') {
|
||||
window.addEventListener('mousemove', resetTimer);
|
||||
window.addEventListener('touchstart', resetTimer);
|
||||
window.addEventListener('touchend', resetTimer);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (defaultStore.state.showingAnimatedImages === 'inactive') {
|
||||
window.removeEventListener('mousemove', resetTimer);
|
||||
window.removeEventListener('touchstart', resetTimer);
|
||||
window.removeEventListener('touchend', resetTimer);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
|
Loading…
Reference in a new issue