Skip to content

Commit a1f87dc

Browse files
authored
fix: animated set page may stick or overshoot (#547)
Closes #537
1 parent c9554ac commit a1f87dc

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/LazyPagerView.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ class LazyPagerViewImpl<ItemT> extends React.Component<
143143
return;
144144
}
145145

146+
// Send paging command.
147+
setTimeout(() => {
148+
UIManager.dispatchViewManagerCommand(
149+
findNodeHandle(this),
150+
animated
151+
? getViewManagerConfig().Commands.setPage
152+
: getViewManagerConfig().Commands.setPageWithoutAnimation,
153+
[page]
154+
);
155+
}, 0);
156+
146157
// Start rendering the destination.
147158
this.setState((prevState) =>
148159
this.computeRenderWindow({
@@ -153,16 +164,6 @@ class LazyPagerViewImpl<ItemT> extends React.Component<
153164
windowLength: prevState.windowLength,
154165
})
155166
);
156-
// Send paging command.
157-
setImmediate(() => {
158-
UIManager.dispatchViewManagerCommand(
159-
findNodeHandle(this),
160-
animated
161-
? getViewManagerConfig().Commands.setPage
162-
: getViewManagerConfig().Commands.setPageWithoutAnimation,
163-
[page]
164-
);
165-
});
166167
}
167168

168169
/**

0 commit comments

Comments
 (0)