This commit is contained in:
26
js/index.js
26
js/index.js
@@ -41,6 +41,26 @@ $(function () {
|
||||
}
|
||||
const idx = index >= 0 && index < bannerData.length ? index : 0;
|
||||
const item = bannerData[idx] || {};
|
||||
// 标签渲染:标题上方的小块标签
|
||||
const $tagsWrap = $("#bannerTags");
|
||||
if ($tagsWrap.length) {
|
||||
$tagsWrap.empty();
|
||||
const rawTags = item.tags || "";
|
||||
const tags = rawTags
|
||||
.split(/[,,]/)
|
||||
.map((t) => t.trim())
|
||||
.filter((t) => t);
|
||||
tags.forEach((tag) => {
|
||||
$tagsWrap.append(
|
||||
`<span class="banner-tag-pill">${tag}</span>`
|
||||
);
|
||||
});
|
||||
if (tags.length === 0) {
|
||||
$tagsWrap.hide();
|
||||
} else {
|
||||
$tagsWrap.show();
|
||||
}
|
||||
}
|
||||
$("#bannerTitle").text(item.title || "");
|
||||
$("#bannerDesc").text(item.description || "");
|
||||
const $btn = $("#bannerButton");
|
||||
@@ -76,6 +96,12 @@ $(function () {
|
||||
}
|
||||
bannerTextTimer = setInterval(() => {
|
||||
current = (current + 1) % bannerData.length;
|
||||
// 淡入动画:先让文案透明,再渐显
|
||||
const $copy = $(".banner-copy");
|
||||
$copy
|
||||
.stop(true, true)
|
||||
.css({ opacity: 0 })
|
||||
.animate({ opacity: 1 }, 400);
|
||||
updateBannerText(current);
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user