virtual-list icon indicating copy to clipboard operation
virtual-list copied to clipboard

fix: wheel handler set passive false

Open xyuanbuilds opened this issue 4 years ago • 6 comments

List.js:248 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

when use preventDefault in wheel event handler, should set passive false

xyuanbuilds avatar Dec 17 '20 06:12 xyuanbuilds

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/h2dfum9mm
✅ Preview: https://virtual-list-git-patch-1.react-component.vercel.app

vercel[bot] avatar Dec 17 '20 06:12 vercel[bot]

Codecov Report

Merging #97 (d106480) into master (fe039bf) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #97   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          470       470           
  Branches        89        89           
=========================================
  Hits           470       470           
Impacted Files Coverage Δ
src/List.tsx 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 fe039bf...d106480. Read the comment docs.

codecov[bot] avatar Dec 17 '20 06:12 codecov[bot]

passive 默认就是 false

componentRef.current.addEventListener('wheel', onRawWheel, {
  passive: true,
});

我看内部使用了 event.preventDefault() ,设置为 true 就使它失效了。

Emmm...不知道有没有其他方案。

beginnerJq avatar May 13 '21 02:05 beginnerJq

passive 默认就是 false

componentRef.current.addEventListener('wheel', onRawWheel, {
  passive: true,
});

我看内部使用了 event.preventDefault() ,设置为 true 就使它失效了。

Emmm...不知道有没有其他方案。

passive: true 是默认值吧,如果内部想要调用event.preventDefault(), 就需要使用false, 否则一堆警告。

yoyo837 avatar May 13 '21 02:05 yoyo837

passive 默认就是 false

componentRef.current.addEventListener('wheel', onRawWheel, {
  passive: true,
});

我看内部使用了 event.preventDefault() ,设置为 true 就使它失效了。 Emmm...不知道有没有其他方案。

passive: true 是默认值吧,如果内部想要调用event.preventDefault(), 就需要使用false, 否则一堆警告。

要看是什么事件,touchstarttouchmove 默认的 passivetrue

beginnerJq avatar May 13 '21 02:05 beginnerJq

这警告不是由于 event.preventDefault() 呀。

相当于是 Chrome 的一个建议,非被动的(non-passive)的事件监听可能会阻塞页面响应。

beginnerJq avatar May 13 '21 02:05 beginnerJq