mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-27 00:06:55 +00:00
@@ -18,7 +18,6 @@
|
||||
"dependencies": {
|
||||
"array-find-index": "^1.0.2",
|
||||
"create-react-class": "^15.6.2",
|
||||
"debounce": "^1.2.0",
|
||||
"deep-assign": "^3.0.0",
|
||||
"fbjs": "^1.0.0",
|
||||
"hyphenate-style-name": "^1.0.3",
|
||||
|
||||
@@ -11,7 +11,6 @@ import type { ViewProps } from '../View';
|
||||
|
||||
import * as React from 'react';
|
||||
import { forwardRef, useRef } from 'react';
|
||||
import debounce from 'debounce';
|
||||
import StyleSheet from '../StyleSheet';
|
||||
import View from '../View';
|
||||
|
||||
@@ -93,6 +92,7 @@ const ScrollViewBase = forwardRef<Props, *>((props, forwardedRef) => {
|
||||
} = props;
|
||||
|
||||
const scrollState = useRef({ isScrolling: false, scrollLastTick: 0 });
|
||||
const scrollTimeout = useRef(null);
|
||||
|
||||
function createPreventableScrollHandler(handler: Function) {
|
||||
return (e: Object) => {
|
||||
@@ -107,9 +107,11 @@ const ScrollViewBase = forwardRef<Props, *>((props, forwardedRef) => {
|
||||
function handleScroll(e: Object) {
|
||||
e.persist();
|
||||
e.stopPropagation();
|
||||
// A scroll happened, so the scroll bumps the debounce.
|
||||
const debouncedOnScrollEnd = debounce(handleScrollEnd, 100);
|
||||
debouncedOnScrollEnd(e);
|
||||
// A scroll happened, so the scroll resets the scrollend timeout.
|
||||
if (scrollTimeout.current != null) {
|
||||
clearTimeout(scrollTimeout.current);
|
||||
}
|
||||
scrollTimeout.current = setTimeout(handleScrollEnd, 100);
|
||||
if (scrollState.current.isScrolling) {
|
||||
// Scroll last tick may have changed, check if we need to notify
|
||||
if (shouldEmitScrollEvent(scrollState.current.scrollLastTick, scrollEventThrottle)) {
|
||||
|
||||
Reference in New Issue
Block a user