Showing
1 changed file
with
17 additions
and
9 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-27 19:49:03 | 2 | * @Date: 2024-09-27 19:49:03 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-10-24 12:47:42 | 4 | + * @LastEditTime: 2024-10-28 15:47:54 |
| 5 | * @FilePath: /hager/src/components/hagerCarousel.vue | 5 | * @FilePath: /hager/src/components/hagerCarousel.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -59,7 +59,7 @@ export default { | ... | @@ -59,7 +59,7 @@ export default { |
| 59 | return { | 59 | return { |
| 60 | selectedImage: 0, // 当前选中的图片索引 | 60 | selectedImage: 0, // 当前选中的图片索引 |
| 61 | startIndex: 0, // 当前显示的缩略图起始索引 | 61 | startIndex: 0, // 当前显示的缩略图起始索引 |
| 62 | - thumbnailsToShow: 4, // 每次显示4个缩略图 | 62 | + thumbnailsToShow: 3, // 每次显示4个缩略图 |
| 63 | isTransitioning: false, // 控制大图的切换动画 | 63 | isTransitioning: false, // 控制大图的切换动画 |
| 64 | }; | 64 | }; |
| 65 | }, | 65 | }, |
| ... | @@ -95,22 +95,30 @@ export default { | ... | @@ -95,22 +95,30 @@ export default { |
| 95 | ensureVisibleThumbnail() { | 95 | ensureVisibleThumbnail() { |
| 96 | if (this.selectedImage < this.startIndex) { | 96 | if (this.selectedImage < this.startIndex) { |
| 97 | // 如果选中的缩略图在当前显示范围的上方,则向上滚动 | 97 | // 如果选中的缩略图在当前显示范围的上方,则向上滚动 |
| 98 | - this.startIndex = this.selectedImage; | 98 | + this.startIndex = this.selectedImage - this.thumbnailsToShow + 1; |
| 99 | } else if (this.selectedImage > this.endIndex) { | 99 | } else if (this.selectedImage > this.endIndex) { |
| 100 | // 如果选中的缩略图在当前显示范围的下方,则向下滚动 | 100 | // 如果选中的缩略图在当前显示范围的下方,则向下滚动 |
| 101 | - this.startIndex = this.selectedImage - this.thumbnailsToShow + 1; | 101 | + this.startIndex = this.selectedImage - this.thumbnailsToShow + 3; |
| 102 | } | 102 | } |
| 103 | }, | 103 | }, |
| 104 | // 切换到下一张图片 | 104 | // 切换到下一张图片 |
| 105 | nextImage() { | 105 | nextImage() { |
| 106 | - if (this.selectedImage < this.images.length - 1) { | 106 | + // if (this.selectedImage < this.images.length - 1) { |
| 107 | - this.selectImage(this.selectedImage + 1); | 107 | + // this.selectImage(this.selectedImage + 1); |
| 108 | + // } | ||
| 109 | + if (this.startIndex < this.images.length - 3) { | ||
| 110 | + this.startIndex += 3 | ||
| 111 | + this.selectImage(this.startIndex); | ||
| 108 | } | 112 | } |
| 109 | }, | 113 | }, |
| 110 | // 切换到上一张图片 | 114 | // 切换到上一张图片 |
| 111 | prevImage() { | 115 | prevImage() { |
| 112 | - if (this.selectedImage > 0) { | 116 | + // if (this.selectedImage > 0) { |
| 113 | - this.selectImage(this.selectedImage - 1); | 117 | + // this.selectImage(this.selectedImage - 1); |
| 118 | + // } | ||
| 119 | + if (this.startIndex > 0) { | ||
| 120 | + this.startIndex -= 3; | ||
| 121 | + this.selectImage(this.startIndex); | ||
| 114 | } | 122 | } |
| 115 | } | 123 | } |
| 116 | }, | 124 | }, |
| ... | @@ -143,7 +151,7 @@ export default { | ... | @@ -143,7 +151,7 @@ export default { |
| 143 | display: flex; | 151 | display: flex; |
| 144 | flex-direction: column; | 152 | flex-direction: column; |
| 145 | align-items: center; | 153 | align-items: center; |
| 146 | - max-height: 220px; /* 限制缩略图容器的高度 */ | 154 | + max-height: 190px; /* 限制缩略图容器的高度 */ |
| 147 | overflow: hidden; | 155 | overflow: hidden; |
| 148 | position: relative; /* 为缩略图滚动效果提供基础 */ | 156 | position: relative; /* 为缩略图滚动效果提供基础 */ |
| 149 | } | 157 | } | ... | ... |
-
Please register or login to post a comment