Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Aug 25, 2020

resolve ant-design/ant-design#26372

Firefox 的鼠标滚动触发的 wheel 事件 deltaY 会比触摸板小很多。导致滚动看起来只有一小段距离,加一个 patch 来监听 FF 事件,如果发现 wheel 和 滚轮 事件数值相同(说明用的是鼠标),则添加一个倍数来滚动。

自己这边测了一下,FF 鼠标滚动和滚屏大概差 8 ~ 11 倍之间

@vercel
Copy link

vercel bot commented Aug 25, 2020

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/react-component/virtual-list/kaafgvlat
✅ Preview: https://virtual-list-git-ff-fix.react-component.vercel.app

@codecov
Copy link

codecov bot commented Aug 25, 2020

Codecov Report

Merging #49 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #49   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        14    +1     
  Lines          345       357   +12     
  Branches        60        63    +3     
=========================================
+ Hits           345       357   +12     
Impacted Files Coverage Δ
src/List.tsx 100.00% <100.00%> (ø)
src/hooks/useFrameWheel.ts 100.00% <100.00%> (ø)
src/utils/isFirefox.ts 100.00% <100.00%> (ø)

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 8108b1d...8ae481a. Read the comment docs.

@zombieJ zombieJ requested a review from afc163 August 25, 2020 07:05
onWheelDelta(offsetRef.current);
// Patch a multiple for Firefox to fix wheel number too small
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
const patchMultiple = isMouseScrollRef.current ? 10 : 1;
Copy link
Member

Choose a reason for hiding this comment

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

这个数字会不会跟着操作系统和硬件发生变化?

Copy link
Member Author

Choose a reason for hiding this comment

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

和 FF 内部的 mousewheel.default.delta_multiplier_y 有关,FF 本身不推荐修改它,可以忽略。如果遇到了再调整:
截屏2020-08-25 下午4 11 21

@@ -0,0 +1,2 @@
const isFF = /Firefox/i.test(navigator.userAgent);
Copy link

Choose a reason for hiding this comment

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

Need to fix for serveer-side-rendering

const isFF = typeof navigator !== 'undefined' && /Firefox/i.test(navigator.userAgent);

Current nodejs error:

ReferenceError: navigator is not defined
vpc-admin: [dev]     at Object.<anonymous> (/Users/nodkz/www/ps/vpc/apps/admin/node_modules/rc-virtual-list/lib/utils/isFirefox.js:7:28)

@nodkz
Copy link

nodkz commented Aug 25, 2020

@zombieJ you break server-side-rendering on nodejs

@nodkz
Copy link

nodkz commented Aug 25, 2020

Hotfix #50

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.

Select组件在火狐上的滚动有明显的卡顿
3 participants