fix(carousel): can not stop the play onhover (#3308)

Signed-off-by: Sepush <sepush@outlook.com>
This commit is contained in:
Sepush 2022-07-19 23:14:31 +08:00 committed by GitHub
parent 6bf10fa3c9
commit f1e4b04257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -10,6 +10,7 @@
- Fix `n-upload`'s `on-error` & `on-finish` props don't allow `() => void` type, closes [#3290](https://github.com/TuSimple/naive-ui/issues/3290).
- Fix `n-select`'s placeholder may overflow if it's long.
- Fix `n-input` has is no indent at the prefix if `type="textarea"` and `:autosize="true"`, closes [#3238](https://github.com/TuSimple/naive-ui/issues/3238).
- Fix `n-carousel`'s `autoplay` prop be `true` `hover` can't stop the play, closes [#3304](https://github.com/TuSimple/naive-ui/issues/3304).
### Feats

View File

@ -10,6 +10,7 @@
- 修复 `n-upload``on-error``on-finish` 属性不允许 `() => void` 类型,关闭 [#3290](https://github.com/TuSimple/naive-ui/issues/3290)
- 修复 `n-select` 的 placeholder 过长时可能溢出
- 修复 `n-input``type="textarea"` 并且 `:autosize="true"` 时添加 prefix 后内容没有对齐,关闭 [#3238](https://github.com/TuSimple/naive-ui/issues/3238)
- 修复 `n-carousel``autoplay``true``hover` 不停止播放,关闭 [#3304](https://github.com/TuSimple/naive-ui/issues/3304)
### Feats

View File

@ -702,7 +702,16 @@ export default defineComponent({
slideSizesRef.effect.run()
}
}
function handleMouseenter (): void {
if (props.autoplay) {
stopAutoplay()
}
}
function handleMouseleave (): void {
if (props.autoplay) {
resetAutoplay()
}
}
onMounted(() => {
watchEffect(resetAutoplay)
requestAnimationFrame(() => (isMountedRef.value = true))
@ -831,6 +840,8 @@ export default defineComponent({
handleTransitionEnd,
handleResize,
handleSlideResize,
handleMouseenter,
handleMouseleave,
isActive: isDisplayActive,
arrowSlotProps: arrowSlotPropsRef,
dotSlotProps: dotSlotPropsRef,
@ -897,6 +908,8 @@ export default defineComponent({
]}
style={this.cssVars as CSSProperties}
{...slidesControlListeners}
onMouseenter={this.handleMouseenter}
onMouseleave={this.handleMouseleave}
>
<VResizeObserver onResize={this.handleResize}>
{{