Skip to content

fix: wheel handler set passive false #97

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

Closed
wants to merge 1 commit into from

Conversation

xyuanbuilds
Copy link

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

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
@vercel
Copy link

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

@codecov
Copy link

codecov bot commented Dec 17, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (fe039bf) to head (d106480).
Report is 154 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #97   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          470       470           
  Branches        89        89           
=========================================
  Hits           470       470           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@beginnerJq
Copy link

passive 默认就是 false

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

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

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

@yoyo837
Copy link
Member

yoyo837 commented May 13, 2021

passive 默认就是 false

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

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

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

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

@beginnerJq
Copy link

passive 默认就是 false

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

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

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

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

@beginnerJq
Copy link

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

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

@afc163 afc163 closed this Jun 20, 2025
@afc163
Copy link
Member

afc163 commented Jun 20, 2025

#281

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.

4 participants