Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
hager
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-10-28 15:49:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7d79cb9ff44ba7835b3041d0acdc7954dcc3af12
7d79cb9f
1 parent
56564222
✨ feat: 产品详情页,图片切换组件显示逻辑修改
李琛意见
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
src/components/hagerCarousel.vue
src/components/hagerCarousel.vue
View file @
7d79cb9
<!--
* @Date: 2024-09-27 19:49:03
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-2
4 12:47:42
* @LastEditTime: 2024-10-2
8 15:47:54
* @FilePath: /hager/src/components/hagerCarousel.vue
* @Description: 文件描述
-->
...
...
@@ -59,7 +59,7 @@ export default {
return {
selectedImage: 0, // 当前选中的图片索引
startIndex: 0, // 当前显示的缩略图起始索引
thumbnailsToShow:
4
, // 每次显示4个缩略图
thumbnailsToShow:
3
, // 每次显示4个缩略图
isTransitioning: false, // 控制大图的切换动画
};
},
...
...
@@ -95,22 +95,30 @@ export default {
ensureVisibleThumbnail() {
if (this.selectedImage < this.startIndex) {
// 如果选中的缩略图在当前显示范围的上方,则向上滚动
this.startIndex = this.selectedImage;
this.startIndex = this.selectedImage
- this.thumbnailsToShow + 1
;
} else if (this.selectedImage > this.endIndex) {
// 如果选中的缩略图在当前显示范围的下方,则向下滚动
this.startIndex = this.selectedImage - this.thumbnailsToShow +
1
;
this.startIndex = this.selectedImage - this.thumbnailsToShow +
3
;
}
},
// 切换到下一张图片
nextImage() {
if (this.selectedImage < this.images.length - 1) {
this.selectImage(this.selectedImage + 1);
// if (this.selectedImage < this.images.length - 1) {
// this.selectImage(this.selectedImage + 1);
// }
if (this.startIndex < this.images.length - 3) {
this.startIndex += 3
this.selectImage(this.startIndex);
}
},
// 切换到上一张图片
prevImage() {
if (this.selectedImage > 0) {
this.selectImage(this.selectedImage - 1);
// if (this.selectedImage > 0) {
// this.selectImage(this.selectedImage - 1);
// }
if (this.startIndex > 0) {
this.startIndex -= 3;
this.selectImage(this.startIndex);
}
}
},
...
...
@@ -143,7 +151,7 @@ export default {
display: flex;
flex-direction: column;
align-items: center;
max-height:
22
0px; /* 限制缩略图容器的高度 */
max-height:
19
0px; /* 限制缩略图容器的高度 */
overflow: hidden;
position: relative; /* 为缩略图滚动效果提供基础 */
}
...
...
Please
register
or
login
to post a comment