From f34f7d0ce0bbad24d7563037849289d27c5b8abf Mon Sep 17 00:00:00 2001 From: dshclm <3321914460@qq.com> Date: Wed, 31 Jul 2024 10:39:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/templates/home/base.html | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/home/base.html b/ruoyi-admin/src/main/resources/templates/home/base.html index 8d342b6..ab28aaa 100644 --- a/ruoyi-admin/src/main/resources/templates/home/base.html +++ b/ruoyi-admin/src/main/resources/templates/home/base.html @@ -559,21 +559,22 @@ var noticeInner = document.querySelector('.notice__inner'); var noticeItems = Array.from(document.querySelectorAll('.notice__item')); var currentIndex = 0; - function showCurrentNotice() { - var numToShow = Math.min(currentIndex + 1, noticeItems.length); - for (var i = 0; i < noticeItems.length; i++) { - noticeItems[i].style.height = ''; - } - for (var i = 0; i < numToShow; i++) { - noticeItems[i].style.height = 'auto'; + if (noticeItems.length > 1) { + function showCurrentNotice() { + var numToShow = Math.min(currentIndex + 1, noticeItems.length); + for (var i = 0; i < noticeItems.length; i++) { + noticeItems[i].style.height = ''; + } + for (var i = 0; i < numToShow; i++) { + noticeItems[i].style.height = 'auto'; + } + noticeInner.style.transform = "translateY(" + ((-noticeItems[currentIndex].clientHeight * currentIndex)*1.39) + "px)"; + noticeInner.style.transition = "all 2.5s"; + noticeInner.scrollTop = noticeItems[currentIndex].offsetTop; + } - noticeInner.style.transform = "translateY(" + ((-noticeItems[currentIndex].clientHeight * currentIndex)*1.39) + "px)"; - noticeInner.style.transition = "all 2.5s"; - noticeInner.scrollTop = noticeItems[currentIndex].offsetTop; + showCurrentNotice(); - } - showCurrentNotice(); - if (noticeItems.length > 1) { setInterval(() => { currentIndex = (currentIndex + 1) % noticeItems.length; showCurrentNotice();