feat(新年活动): 按钮长文本设置滚动动画

This commit is contained in:
hzj 2026-01-07 11:29:52 +08:00
parent b7ecc6f0f5
commit e93da8dca5

View File

@ -122,6 +122,7 @@
v-for="tag in tabList"
style="
width: 50%;
min-width: 0;
height: 100%;
display: flex;
@ -131,18 +132,59 @@
@click="handleBt(tag.value)"
>
<div
style="width: 60%; min-width: 0; overflow: hidden; position: relative"
v-if="isTextOverflow(tag.name)"
>
<!-- 滚动容器 -->
<div class="scroll-wrapper">
<!-- 第一套内容 -->
<div class="scroll-content">
<div
style="
color: #fff;
font-size: 1.5em;
font-weight: 700;
text-shadow: 0 1px 1px #712eb1;
white-space: nowrap;
line-height: 1.2em;
"
>
{{ tag.name }}
</div>
</div>
<!-- 第二套内容间隔30px -->
<div class="scroll-content">
<div
style="
color: #fff;
font-size: 1.5em;
font-weight: 700;
text-shadow: 0 1px 1px #712eb1;
white-space: nowrap;
line-height: 1.2em;
"
>
{{ tag.name }}
</div>
</div>
</div>
</div>
<!-- 不滚动的文本如果长度不需要滚动 -->
<div
v-else
style="
width: 50%;
width: 60%;
min-width: 0;
color: #fff;
font-size: 1em;
font-size: 1.5em;
font-weight: 700;
text-shadow: 0 1px 1px #712eb1;
text-align: center;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.2em;
"
>
@ -607,7 +649,8 @@
gap: 2vw;
padding: 12px;
border-radius: 12px;
background: linear-gradient(
background:
linear-gradient(
99deg,
rgba(211, 212, 213, 0.15) 12.86%,
rgba(139, 145, 147, 0.15) 15.34%,
@ -702,7 +745,8 @@
z-index: 2;
margin: 0 4vw;
border-radius: 12px;
background: linear-gradient(
background:
linear-gradient(
99deg,
rgba(211, 212, 213, 0.15) 12.86%,
rgba(139, 145, 147, 0.15) 15.34%,
@ -757,7 +801,8 @@
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
@ -871,7 +916,8 @@
<div
style="
border-radius: 12px;
background: linear-gradient(
background:
linear-gradient(
99deg,
rgba(211, 212, 213, 0.15) 12.86%,
rgba(139, 145, 147, 0.15) 15.34%,
@ -982,7 +1028,8 @@
<div
style="
border-radius: 12px;
background: linear-gradient(
background:
linear-gradient(
99deg,
rgba(211, 212, 213, 0.15) 12.86%,
rgba(139, 145, 147, 0.15) 15.34%,
@ -1146,7 +1193,8 @@
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
@ -1168,7 +1216,8 @@
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
@ -1211,7 +1260,8 @@
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
@ -1288,7 +1338,8 @@
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
@ -1835,6 +1886,30 @@ const startCountdown = () => {
countdownTimer = setInterval(calculateCountdown, 1000)
}
//
const isTextOverflow = (text) => {
//
const tempDiv = document.createElement('div')
tempDiv.style.position = 'absolute'
tempDiv.style.visibility = 'hidden'
tempDiv.style.whiteSpace = 'nowrap'
tempDiv.style.fontSize = '1.5em'
tempDiv.style.fontWeight = '700'
tempDiv.style.textShadow = '0 1px 1px #712eb1'
tempDiv.style.lineHeight = '1.2em'
tempDiv.textContent = text
document.body.appendChild(tempDiv)
//
const containerWidth = window.innerWidth * 0.94 * 0.5 * 0.6 //
const textWidth = tempDiv.getBoundingClientRect().width
document.body.removeChild(tempDiv)
//
return textWidth > containerWidth
}
const taskList = ref([])
//
@ -2008,7 +2083,7 @@ const transfer = async () => {
t('transfer_success', {
price: selectedCoin.value.price,
name: selectedPayee.value?.name,
})
}),
)
} else {
showError(t('transfer_failed', { price: selectedCoin.value.price }))
@ -2166,7 +2241,7 @@ const sweepstakes = async (consecutive = 1) => {
const resItem = resOnceDraw.body //
//
const index = activity.value.prizeList.findIndex(
(prize) => prize.prizeName == resItem?.prize.prizeName
(prize) => prize.prizeName == resItem?.prize.prizeName,
) //
console.log('index:', index)
await startLottery(index)
@ -2183,7 +2258,7 @@ const sweepstakes = async (consecutive = 1) => {
//
let index = activity.value.prizeList.findIndex(
(prize) => prize.prizeName == result.value[0]?.prize.prizeName
(prize) => prize.prizeName == result.value[0]?.prize.prizeName,
)
console.log('index:', index)
await startLottery(index)
@ -2760,8 +2835,56 @@ onUnmounted(() => {
display: none;
}
/* 金币网格 */
//
.scroll-wrapper {
display: flex;
width: fit-content;
}
.scroll-content {
display: flex;
align-items: center;
gap: 4px;
}
@keyframes scroll-left {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
}
@keyframes scroll-right {
0% {
transform: translateX(0);
}
100% {
transform: translateX(50%);
}
}
[dir='ltr'] .scroll-content {
margin-left: 30px;
}
[dir='rtl'] .scroll-content {
margin-left: auto;
margin-right: 30px;
}
[dir='ltr'] .scroll-wrapper {
animation: scroll-left 5s linear infinite;
will-change: transform;
}
[dir='rtl'] .scroll-wrapper {
animation: scroll-right 5s linear infinite;
will-change: transform;
}
/* 金币网格 */
.coin-item {
display: flex;
flex-direction: column;
@ -2779,8 +2902,10 @@ onUnmounted(() => {
rgba(151, 176, 255, 0.4) 60.22%,
rgba(220, 228, 255, 0.4) 103.12%
);
box-shadow: 0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08), 0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
box-shadow:
0 36.858px 13.981px 0 rgba(151, 176, 255, 0.02),
0 20.335px 12.71px 0 rgba(151, 176, 255, 0.08),
0 8.897px 8.897px 0 rgba(151, 176, 255, 0.13),
0 2.542px 5.084px 0 rgba(151, 176, 255, 0.15);
backdrop-filter: blur(4.5px);
}
@ -2788,8 +2913,11 @@ onUnmounted(() => {
.coin-item.selected {
border-radius: 12px;
border: 2px solid #80d7ff;
box-shadow: -0.25px -0.25px 1px 0 #16bcff, 0.25px 0.25px 1px 0 #16bcff,
0 0 3px 0 rgba(22, 188, 255, 0.8), 0 0 5px 0 rgba(22, 188, 255, 0.6),
box-shadow:
-0.25px -0.25px 1px 0 #16bcff,
0.25px 0.25px 1px 0 #16bcff,
0 0 3px 0 rgba(22, 188, 255, 0.8),
0 0 5px 0 rgba(22, 188, 255, 0.6),
0 0 4px 0 rgba(0, 83, 117, 0.3);
}