We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 38189eb commit 1670f5cCopy full SHA for 1670f5c
1 file changed
src/layouts/MainGridLayout.astro
@@ -670,11 +670,16 @@ const transparentClass = shouldEnableTransparency
670
return images || null;
671
};
672
673
+ const container = document.getElementById('banner-single-container');
674
+
675
+ // 检查容器是否已有图片,避免在页面切换或缩放时重复创建
676
+ if (container.querySelector('img')) {
677
+ return;
678
+ }
679
680
const desktopSrc = getRandomImage(desktopImages, 'banner_desktop_index');
681
const mobileSrc = getRandomImage(mobileImages, 'banner_mobile_index');
682
- const container = document.getElementById('banner-single-container');
-
683
if (mobileSrc) {
684
const mobileImg = document.createElement('img');
685
mobileImg.alt = 'Mobile banner image of the blog';
0 commit comments