Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Carousel): refactor Carousel #2061

Merged
merged 28 commits into from
Jan 9, 2022

Conversation

nooooooom
Copy link
Contributor

@nooooooom nooooooom commented Dec 28, 2021

@vercel
Copy link

vercel bot commented Dec 28, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tusimple/naive-ui/AXvmaZM3PGLJ9hJrRXMrzFRD21aA
✅ Preview: https://naive-ui-git-fork-nooooooom-refactor-carousel-tusimple.vercel.app

@lgtm-com
Copy link

lgtm-com bot commented Dec 28, 2021

This pull request introduces 1 alert when merging 7ca2a6b into 2870228 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@XieZongChen
Copy link
Collaborator

更新一下测试

@nooooooom
Copy link
Contributor Author

更新一下测试

😉想一块去了

@codecov
Copy link

codecov bot commented Dec 28, 2021

Codecov Report

Merging #2061 (9d840b3) into main (6046df1) will increase coverage by 0.13%.
The diff coverage is 53.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2061      +/-   ##
==========================================
+ Coverage   64.51%   64.64%   +0.13%     
==========================================
  Files         898      905       +7     
  Lines       17622    18129     +507     
  Branches     4176     4326     +150     
==========================================
+ Hits        11368    11719     +351     
- Misses       5464     5588     +124     
- Partials      790      822      +32     
Impacted Files Coverage Δ
src/carousel/src/styles/index.cssr.ts 100.00% <ø> (ø)
src/carousel/styles/light.ts 100.00% <ø> (ø)
src/modal/src/BodyWrapper.tsx 47.56% <ø> (ø)
src/carousel/src/CarouselDots.tsx 29.31% <29.31%> (ø)
src/carousel/src/utils.ts 52.94% <52.94%> (ø)
src/carousel/src/Carousel.tsx 54.98% <53.09%> (+17.25%) ⬆️
src/carousel/src/CarouselItem.tsx 82.85% <82.85%> (ø)
src/carousel/src/CarouselArrow.tsx 87.50% <87.50%> (ø)
src/_utils/vue/keep.ts 83.33% <100.00%> (ø)
src/carousel/index.ts 100.00% <100.00%> (ø)
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6046df1...9d840b3. Read the comment docs.

@07akioni
Copy link
Collaborator

2021-12-31.12.47.32.mov

每次 refresh 的时候都会默认播放一下,需要处理

@07akioni
Copy link
Collaborator

image

Card 缺少点击左和点击右图切换的效果

@07akioni
Copy link
Collaborator

07akioni commented Dec 30, 2021

image

Outline �需要干掉

@07akioni
Copy link
Collaborator

07akioni commented Dec 30, 2021

image

这个用起来感觉不是很正常的样子

用 left arrow, right arrow, tab, enter 感觉都不太对

@nooooooom
Copy link
Contributor Author

2021-12-31.12.47.32.mov
每次 refresh 的时候都会默认播放一下,需要处理

是有这个问题,我处理一下

@07akioni
Copy link
Collaborator

07akioni commented Jan 4, 2022

2022-01-05.2.26.47.mov
2022-01-05.2.27.32.mov

Transition 还是有问题

你应该是需要使用 isMounted 来判断一下应不应该 apply transtion

naive 很多地地方都会针对性的在 mounted 的时候关掉 transition

Copy link
Collaborator

@07akioni 07akioni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. PC 上默认还是把拖拽关掉
  2. 方格没法 focus,需要支持 a11y

image

  1. 控制一下用户的点击速度,不然动画会出问题,不应该出现从右往左跳的

正确:

2022-01-05.2.50.58.mov

错误:

2022-01-05.2.46.32.mov

import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { on, off } from 'evtd'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package import 都放在最前面

isTouchEvent,
getRealityIndex
} from './utils'
import { VResizeObserver } from 'vueuc'
Copy link
Collaborator

@07akioni 07akioni Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package import 都放在最前面

const nextRealityIndex = getNextRealityIndex(index)
return nextRealityIndex !== null && nextRealityIndex === index
}
function isDisabledPrev (): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isPrevDisabled

Comment on lines 62 to 64
{
[`${mergedClsPrefix}-carousel__arrow--disabled`]: this.isDisabledPrev()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.isDisabledPrev() && ${mergedClsPrefix}-carousel__arrow--disabled

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么搞行数少,好看点

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022-01-05.2.26.47.mov
2022-01-05.2.27.32.mov
Transition 还是有问题

你应该是需要使用 isMounted 来判断一下应不应该 apply transtion

naive 很多地地方都会针对性的在 mounted 的时候关掉 transition

好,这个应该是监听size的时候动的。不得不说你的电脑刷新好快,我都复现不出这种效果。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M1 还是牛逼的 😂

@nooooooom
Copy link
Contributor Author

nooooooom commented Jan 5, 2022

  1. PC 上默认还是把拖拽关掉
  2. 方格没法 focus,需要支持 a11y

image

  1. 控制一下用户的点击速度,不然动画会出问题,不应该出现从右往左跳的

正确:

2022-01-05.2.50.58.mov
错误:

2022-01-05.2.46.32.mov

了解,内部其实做了切换的缓冲处理,只是丢给用户的 method 上面没有处理

  1. PC 上默认还是把拖拽关掉
  2. 方格没法 focus,需要支持 a11y

image

  1. 控制一下用户的点击速度,不然动画会出问题,不应该出现从右往左跳的

正确:

2022-01-05.2.50.58.mov
错误:

2022-01-05.2.46.32.mov

这个实例是自己自定义的,用的作用域插槽,所以部分事件没有内部的处理,内部的点可以focus

@nooooooom
Copy link
Contributor Author

给 DEMO 搞一个套 <a /> 的,看看点击之后能不能跳走,有没有被咱们的时间处理器影响

没影响到,我们只对拖拽时的点击事件进行了阻止

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

Preview

OK

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

image

键盘控制的时候切换一下焦点,现在焦点会一直停留在聚焦的地方

这个还没有解决

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

image

这个类型写的不是合法的 ts 类型

({ x: string }) => void 不合法

(info: { x: string }) => void 合法

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

image

改成 prev,next 和 to 吧

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

image

格式上缺空格 { xxx: y }

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

Card 切换模式的感觉有点问题。

2022-01-09.5.21.45.mov
2022-01-09.5.22.22.mov

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

Card 模式还有一个问题,从第一个会直接切换到第三个

2022-01-09.5.23.37.mov

@07akioni
Copy link
Collaborator

07akioni commented Jan 9, 2022

这个 DEMO 在不同模式切换的效果不好,给 carousel 来个 key 吧,强行切换 DOM

<n-carousel :key="type" />

2022-01-09.5.24.13.mov

@lgtm-com
Copy link

lgtm-com bot commented Jan 9, 2022

This pull request introduces 1 alert when merging 04264d5 into 71fa285 - view on LGTM.com

new alerts:

  • 1 for Useless conditional

@07akioni 07akioni merged commit c0d62e3 into tusen-ai:main Jan 9, 2022
@nooooooom nooooooom deleted the refactor-carousel branch February 16, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants