Skip to content

Commit

Permalink
fix(carousel): trigger incorrect current-index value on arrow butto…
Browse files Browse the repository at this point in the history
…n click with single image, closes #5130 (#5141)

Co-authored-by: 07akioni <07akioni2@gmail.com>
  • Loading branch information
jizai1125 and 07akioni authored Dec 19, 2023
1 parent 6483e1d commit 3a9798d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fix `n-time-picker` formatting (format="HH: mm: ss. SSS") preventing modification of milliseconds in the edit box, closes [#5224](https://github.com/tusen-ai/naive-ui/issues/5224).
- Fix `n-notification` notification clips out of screen when screen width is less than 400px wide.
- Fix `n-carousel` transition effect incorrect when using the `slide` effect in loop mode with only two elements, closes [#4323](https://github.com/tusen-ai/naive-ui/issues/4323).
- Fix `n-carousel` trigger incorrect `current-index` value on arrow button click with single image, closes [#5130](https://github.com/tusen-ai/naive-ui/issues/5130).

### Features

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- 修复 `n-time-picker` 时间选择器格式化(`format="HH:mm:ss.SSS"`)后无法在编辑框内修改毫秒数的问题,关闭 [#5224](https://github.com/tusen-ai/naive-ui/issues/5224)
- 修复 `n-notification` 通知在屏幕宽度小于 400px 的时候溢出屏幕
- 修复 `n-carousel` 在只有两个元素时,过渡效果为 `slide` 且循环播放时过渡效果有问题,关闭 [#4323](https://github.com/tusen-ai/naive-ui/issues/4323)
- 修复 `n-carousel` 在只有一张图片时点击箭头切换按钮触发的 `current-index` 值不正确,关闭 [#5130](https://github.com/tusen-ai/naive-ui/issues/5130)

### Features

Expand Down
6 changes: 5 additions & 1 deletion src/carousel/src/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export default defineComponent({
const duplicatedableRef = computed(
// duplicate the copy operation in `slide` mode,
// because only its DOM is sequence layout
() => props.loop && props.slidesPerView === 1 && sequenceLayoutRef.value
() =>
props.loop &&
props.slidesPerView === 1 &&
sequenceLayoutRef.value &&
totalViewRef.value > 1
)
// user wants to control the transition animation
const userWantsControlRef = computed(() => props.effect === 'custom')
Expand Down

0 comments on commit 3a9798d

Please sign in to comment.