Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-virtual-list

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-virtual-list - npm Package Compare versions

Comparing version 3.0.5 to 3.0.6

es/utils/isFirefox.d.ts

7

es/hooks/useFrameWheel.d.ts

@@ -1,1 +0,6 @@

export default function useFrameWheel(inVirtual: boolean, onWheelDelta: (offset: number) => void): (event: MouseWheelEvent) => void;
interface FireFoxDOMMouseScrollEvent {
detail: number;
preventDefault: Function;
}
export default function useFrameWheel(inVirtual: boolean, onWheelDelta: (offset: number) => void): [(e: WheelEvent) => void, (e: FireFoxDOMMouseScrollEvent) => void];
export {};
import { useRef } from 'react';
import raf from "rc-util/es/raf";
import isFF from '../utils/isFirefox';
export default function useFrameWheel(inVirtual, onWheelDelta) {
var offsetRef = useRef(0);
var nextFrameRef = useRef(null);
var nextFrameRef = useRef(null); // Firefox patch
var wheelValueRef = useRef(null);
var isMouseScrollRef = useRef(false);
function onWheel(event) {
if (!inVirtual) return; // Proxy of scroll events
event.preventDefault();
if (!isFF) {
event.preventDefault();
}
raf.cancel(nextFrameRef.current);
offsetRef.current += event.deltaY;
wheelValueRef.current = event.deltaY;
nextFrameRef.current = raf(function () {
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
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
onWheelDelta(offsetRef.current * patchMultiple);
offsetRef.current = 0;
});
} // A patch for firefox
function onFireFoxScroll(event) {
if (!inVirtual) return; // Firefox level stop
event.preventDefault();
isMouseScrollRef.current = event.detail === wheelValueRef.current;
}
return onWheel;
return [onWheel, onFireFoxScroll];
}

23

es/List.js

@@ -187,11 +187,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var keepInRange = useInRange(scrollHeight, height); // ================================ Scroll ================================
// Since this added in global,should use ref to keep update
var onRawWheel = useFrameWheel(inVirtual, function (offsetY) {
syncScrollTop(function (top) {
var newTop = keepInRange(top + offsetY);
return newTop;
});
});
function onScrollBar(newScrollTop) {

@@ -216,8 +208,21 @@ var newTop = keepInRange(newScrollTop);

onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
}
} // Since this added in global,should use ref to keep update
var _useFrameWheel = useFrameWheel(inVirtual, function (offsetY) {
syncScrollTop(function (top) {
var newTop = keepInRange(top + offsetY);
return newTop;
});
}),
_useFrameWheel2 = _slicedToArray(_useFrameWheel, 2),
onRawWheel = _useFrameWheel2[0],
onFireFoxScroll = _useFrameWheel2[1];
React.useEffect(function () {
componentRef.current.addEventListener('wheel', onRawWheel);
componentRef.current.addEventListener('DOMMouseScroll', onFireFoxScroll);
return function () {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll);
};

@@ -224,0 +229,0 @@ }, [inVirtual]); // ================================= Ref ==================================

@@ -1,1 +0,6 @@

export default function useFrameWheel(inVirtual: boolean, onWheelDelta: (offset: number) => void): (event: MouseWheelEvent) => void;
interface FireFoxDOMMouseScrollEvent {
detail: number;
preventDefault: Function;
}
export default function useFrameWheel(inVirtual: boolean, onWheelDelta: (offset: number) => void): [(e: WheelEvent) => void, (e: FireFoxDOMMouseScrollEvent) => void];
export {};

@@ -12,2 +12,4 @@ "use strict";

var _isFirefox = _interopRequireDefault(require("../utils/isFirefox"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -17,8 +19,13 @@

var offsetRef = (0, _react.useRef)(0);
var nextFrameRef = (0, _react.useRef)(null);
var nextFrameRef = (0, _react.useRef)(null); // Firefox patch
var wheelValueRef = (0, _react.useRef)(null);
var isMouseScrollRef = (0, _react.useRef)(false);
function onWheel(event) {
if (!inVirtual) return; // Proxy of scroll events
event.preventDefault();
if (!_isFirefox.default) {
event.preventDefault();
}

@@ -28,9 +35,21 @@ _raf.default.cancel(nextFrameRef.current);

offsetRef.current += event.deltaY;
wheelValueRef.current = event.deltaY;
nextFrameRef.current = (0, _raf.default)(function () {
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
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
onWheelDelta(offsetRef.current * patchMultiple);
offsetRef.current = 0;
});
} // A patch for firefox
function onFireFoxScroll(event) {
if (!inVirtual) return; // Firefox level stop
event.preventDefault();
isMouseScrollRef.current = event.detail === wheelValueRef.current;
}
return onWheel;
return [onWheel, onFireFoxScroll];
}

@@ -29,3 +29,3 @@ "use strict";

var _useFrameWheel = _interopRequireDefault(require("./hooks/useFrameWheel"));
var _useFrameWheel3 = _interopRequireDefault(require("./hooks/useFrameWheel"));

@@ -214,11 +214,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var keepInRange = (0, _useInRange.default)(scrollHeight, height); // ================================ Scroll ================================
// Since this added in global,should use ref to keep update
var onRawWheel = (0, _useFrameWheel.default)(inVirtual, function (offsetY) {
syncScrollTop(function (top) {
var newTop = keepInRange(top + offsetY);
return newTop;
});
});
function onScrollBar(newScrollTop) {

@@ -243,8 +235,21 @@ var newTop = keepInRange(newScrollTop);

onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
}
} // Since this added in global,should use ref to keep update
var _useFrameWheel = (0, _useFrameWheel3.default)(inVirtual, function (offsetY) {
syncScrollTop(function (top) {
var newTop = keepInRange(top + offsetY);
return newTop;
});
}),
_useFrameWheel2 = _slicedToArray(_useFrameWheel, 2),
onRawWheel = _useFrameWheel2[0],
onFireFoxScroll = _useFrameWheel2[1];
React.useEffect(function () {
componentRef.current.addEventListener('wheel', onRawWheel);
componentRef.current.addEventListener('DOMMouseScroll', onFireFoxScroll);
return function () {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll);
};

@@ -251,0 +256,0 @@ }, [inVirtual]); // ================================= Ref ==================================

{
"name": "rc-virtual-list",
"version": "3.0.5",
"version": "3.0.6",
"description": "React Virtual List Component",

@@ -5,0 +5,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc