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: VirtualizedList passive event listener warning #2601

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type EventOptions = {

const emptyFunction = () => {};

function supportsPassiveEvents(): boolean {
export function supportsPassiveEvents(): boolean {
let supported = false;
// Check if browser supports event with passive listeners
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ import {
import invariant from 'fbjs/lib/invariant';
import nullthrows from 'nullthrows';
import * as React from 'react';
import { supportsPassiveEvents } from '../../../modules/addEventListener';

export type {RenderItemProps, RenderItemType, Separators};

const __DEV__ = process.env.NODE_ENV !== 'production';

const ON_EDGE_REACHED_EPSILON = 0.001;
const canUsePassiveEvents = supportsPassiveEvents();

let _usedIndexForKey = false;
let _keylessItemComponentName: string = '';
Expand Down Expand Up @@ -746,7 +748,8 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
setupWebWheelHandler() {
if (this._scrollRef && this._scrollRef.getScrollableNode) {
this._scrollRef.getScrollableNode().addEventListener('wheel',
this.invertedWheelEventHandler
this.invertedWheelEventHandler,
canUsePassiveEvents ? { passive: true } : false
tienifr marked this conversation as resolved.
Show resolved Hide resolved
);
} else {
setTimeout(() => this.setupWebWheelHandler(), 50);
Expand Down