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(comp:spin): compatible with the resize of target, when useSpin is… #1273

Merged
merged 1 commit into from
Nov 13, 2022

Conversation

liuzaijiang
Copy link
Contributor

@liuzaijiang liuzaijiang commented Nov 13, 2022

… used

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

What is the current behavior?

  1. 当使用useSpin遮住target时,如果target发生了resize事件,spin无法适配
  2. IxSpinProvider组件产生了多余的ix-spin-provider节点

What is the new behavior?

  1. useSpin是将spin组件传送到target内部,从而实现遮罩效果,若target不存在滚动条则可以使用css的absolute定位去遮住整个区域;但当存在滚动条时且用户滚动时,无法满足;
  • 解决方案为: 当存在滚动条时动态设置spin的宽高为整个target的宽高,从而实现遮住滚动区域的效果,反之利用css的absolute解决;
    tips: 还有一个解决方案为不设置宽高,而是动态设置spin的偏移 (transform: translate),只遮住可视区域,但是此方案需要同时处理scroll和resize两个事件,而且当滚动条滚得太快时,视觉上会有晃动的,所以放弃。

    此解决方案有一个难点在于当target产生resize事件时,由于spin拥有了宽高且位于target内部,所以无法准确获取当前target产生resize之后的宽高从而判断是否还存在滚动条,所以此难点解决办法为,当产生resize时,将spin宽高置为0,在nextTick中再进行判断

  1. 由于vue3可以使用无根节点的组件,所以直接去除ix-spin-provider节点 即可

Other information

@idux-bot
Copy link

idux-bot bot commented Nov 13, 2022

This preview will be available after the AzureCI is passed.

@codecov
Copy link

codecov bot commented Nov 13, 2022

Codecov Report

Merging #1273 (c5b8cfb) into main (99e4ddd) will decrease coverage by 0.05%.
The diff coverage is 48.64%.

@@            Coverage Diff             @@
##             main    #1273      +/-   ##
==========================================
- Coverage   93.05%   92.99%   -0.06%     
==========================================
  Files         320      320              
  Lines       29469    29499      +30     
  Branches     3344     3346       +2     
==========================================
+ Hits        27422    27433      +11     
- Misses       2047     2066      +19     
Impacted Files Coverage Δ
packages/components/spin/src/SpinProvider.tsx 86.63% <45.71%> (-8.85%) ⬇️
packages/components/spin/src/types.ts 100.00% <100.00%> (ø)
packages/components/tree/src/Tree.tsx 95.13% <0.00%> (+0.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@danranVm danranVm merged commit bb2b4fd into IDuxFE:main Nov 13, 2022
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.

None yet

2 participants