Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,19 @@
to {
transform: translateX(-25%);
}
}

.scroll-text {
display: inline-block;
animation: scroll-left 3s ease-in-out infinite alternate;
will-change: transform;
}

@keyframes scroll-left {
from {
transform: translateX(0);
}
to {
transform: translateX(calc(-100% + 6rem));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const {
handleScroll,
} = useGsap(scrollContainerRef, liRefs, isScroll, prizeShow, props.temporaryPrizeShow)

// 超过 6 个字符就滚动
function shouldScroll(name: string) {
return (name || '').length > 6
}

// 获取ulContainerRef的高度
function getUlContainerHeight() {
if (ulContainerRef.value) {
Expand Down Expand Up @@ -90,12 +95,16 @@ watch ([prizeShow, () => props.temporaryPrizeShow], (val) => {
>
</figure>
<div class="items-center p-0 card-body">
<div class="tooltip tooltip-left w-full pl-1" :data-tip="item.name">
<div class="w-24 overflow-hidden" :data-tip="item.name">
<h2
class="w-24 p-0 m-0 overflow-hidden card-title whitespace-nowrap text-ellipsis"
v-if="shouldScroll(item.name)"
class="p-0 m-0 card-title whitespace-nowrap scroll-text"
>
{{ item.name }}
</h2>
<h2 v-else class="p-0 m-0 card-title whitespace-nowrap text-ellipsis overflow-hidden">
{{ item.name }}
</h2>
</div>
<p class="absolute z-40 p-0 m-0 text-gray-300/80 mt-9">
{{ item.isUsedCount }}/{{
Expand Down
29 changes: 26 additions & 3 deletions src/views/Home/components/PrizeList/parts/TemporaryList.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<script setup lang='ts'>
import type { IPrizeConfig } from '@/types/storeType'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'

import defaultPrizeImage from '@/assets/images/龙.png'

defineProps<{
const props = defineProps<{
temporaryPrize: IPrizeConfig
addTemporaryPrize: () => void
deleteTemporaryPrize: () => void
}>()

const { t } = useI18n()

// 超过 6 个字符就滚动
const shouldScroll = computed(() => {
const name = props.temporaryPrize?.name || ''
return name.length > 6
})
</script>

<template>
Expand All @@ -25,8 +32,11 @@ const { t } = useI18n()
<img v-else :src="defaultPrizeImage" alt="Prize" class="object-cover h-full rounded-xl">
</figure>
<div class="items-center p-0 text-center card-body">
<div class="tooltip tooltip-left" :data-tip="temporaryPrize.name">
<h2 class="p-0 m-0 overflow-hidden w-28 card-title whitespace-nowrap text-ellipsis">
<div class="w-28 overflow-hidden" :data-tip="temporaryPrize.name">
<h2
class="p-0 m-0 card-title whitespace-nowrap"
:class="shouldScroll ? 'scroll-text' : 'text-ellipsis overflow-hidden'"
>
{{ temporaryPrize.name }}
</h2>
</div>
Expand Down Expand Up @@ -55,5 +65,18 @@ const { t } = useI18n()
</template>

<style scoped>
.scroll-text {
display: inline-block;
animation: scroll-left 3s ease-in-out infinite alternate;
will-change: transform;
}

@keyframes scroll-left {
from {
transform: translateX(0);
}
to {
transform: translateX(calc(-100% + 7rem));
}
}
</style>