Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 3 additions & 8 deletions src/reanimated2/NativeReanimated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import reanimatedJS from '../js-reanimated';
import { shouldBeUseWeb } from '../PlatformChecker';
import { NativeReanimated } from './NativeReanimated';

let exportedModule;
if (shouldBeUseWeb()) {
exportedModule = reanimatedJS;
} else {
exportedModule = new NativeReanimated();
}

export default exportedModule as NativeReanimated;
export default (shouldBeUseWeb()
? reanimatedJS
: new NativeReanimated()) as NativeReanimated;
9 changes: 9 additions & 0 deletions src/reanimated2/component/FlatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ export const ReanimatedFlatList = forwardRef(
: styles.verticallyInverted
: undefined;

// Set default scrollEventThrottle, because user expects
// to have continuous scroll events and
// react-native defaults it to 50 for FlatLists.
// We set it to 1 so we have peace until
// there are 960 fps screens.
if (!('scrollEventThrottle' in restProps)) {
restProps.scrollEventThrottle = 1;
}

const cellRenderer = React.useMemo(
() => createCellRenderer(itemLayoutAnimation, cellStyle),
[cellStyle]
Expand Down
10 changes: 6 additions & 4 deletions src/reanimated2/component/ScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export const AnimatedScrollView: AnimatedScrollView = forwardRef(
);
}

if (!restProps.scrollEventThrottle) {
// Set default scrollEventThrottle to 8, because user expects
// to have continuous scroll events
restProps.scrollEventThrottle = 8;
// Set default scrollEventThrottle, because user expects
// to have continuous scroll events.
// We set it to 1 so we have peace until
// there are 960 fps screens.
if (!('scrollEventThrottle' in restProps)) {
restProps.scrollEventThrottle = 1;
}

return <AnimatedScrollViewComponent ref={aref} {...restProps} />;
Expand Down
5 changes: 1 addition & 4 deletions src/reanimated2/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ export function setupMicrotasks() {

let microtasksQueue: Array<() => void> = [];
let isExecutingMicrotasksQueue = false;

// @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number
global.queueMicrotask = (callback: () => void): number => {
global.queueMicrotask = (callback: () => void) => {
microtasksQueue.push(callback);
return -1;
};

global.__callMicrotasks = () => {
Expand Down