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

fix: transform logic #38

Merged
merged 6 commits into from
Apr 28, 2022
Merged

fix: transform logic #38

merged 6 commits into from
Apr 28, 2022

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Apr 28, 2022

resolve ant-design/ant-design#35265

有几个原因:

  • querySelector 不能用 nth 因为 CSSMotion 转换中,thumb 节点也算在 nth 中导致计数不正确
  • CSSMotion 在动画过程中如果点击其他 Option,虽然 current.to 切换成了下一个节点但是不会更新 React 生命周期,CSSMotion 还是走的原来的目标点

修复:

  • 抽离 CSSMotion 部分,将 selected 部分稍作解耦
  • CSSMotion active 通过 css variable 来动态更新目标位置以达到即便动画过程中也可以到目标点
  • 通过 querySelectAll 选择选项元素

@github-actions
Copy link

github-actions bot commented Apr 28, 2022

🎊 PR Preview 344e2bb has been successfully built and deployed to https://react-component-segmented-preview-pr-38.surge.sh

🕐 Build time: 181.143s

🤖 By surge-preview

@vagusX
Copy link
Member

vagusX commented Apr 28, 2022

现在好像没有默认选中项了

image

Fixed at 72b0e19 @zombieJ

@vagusX vagusX self-requested a review April 28, 2022 07:48
@vagusX
Copy link
Member

vagusX commented Apr 28, 2022

这个 ref demo 好像没有动画了 https://react-component-segmented-preview-pr-38.surge.sh/demo/refs/

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #38 (344e2bb) into master (921d58f) will decrease coverage by 1.05%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##            master      #38      +/-   ##
===========================================
- Coverage   100.00%   98.94%   -1.06%     
===========================================
  Files            1        3       +2     
  Lines           81       95      +14     
  Branches        17       18       +1     
===========================================
+ Hits            81       94      +13     
- Misses           0        1       +1     
Impacted Files Coverage Δ
src/MotionThumb.tsx 100.00% <100.00%> (ø)
src/index.tsx 100.00% <100.00%> (ø)
index.js 0.00% <0.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@zombieJ
Copy link
Member Author

zombieJ commented Apr 28, 2022

这个 ref demo 好像没有动画了 https://react-component-segmented-preview-pr-38.surge.sh/demo/refs/

看了一下 composeRef 没有 memo 导致每次 render 都是新的 func,让 container.current 用的时候变 null 了。fixed,thx~

@zombieJ zombieJ changed the title [WIP] Fix: transform logic fix: transform logic Apr 28, 2022
@vagusX vagusX merged commit a1f5a8c into master Apr 28, 2022
@vagusX vagusX deleted the react-18 branch April 28, 2022 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmented 组件在受控模式下切换状态不正确
2 participants