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: wheel handler set passive false #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
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

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.

@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)的事件监听可能会阻塞页面响应。

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.

3 participants