From f9a8b5831b4872e317210706262f412f430cca8f Mon Sep 17 00:00:00 2001 From: Faruq Rasid Date: Sat, 29 Oct 2022 15:55:34 +0800 Subject: [PATCH 1/2] Use window width for getItemLayout --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index ad23272..acb07fd 100755 --- a/src/index.js +++ b/src/index.js @@ -179,6 +179,8 @@ class Onboarding extends Component { } : onSkip; + const windowWidth = Dimensions.get('window').width; + return ( ( + {length: windowWidth, offset: windowWidth * index, index} + )} extraData={ this.state.width // ensure that the list re-renders on orientation change } From 890fa67473d3b48fee32c1406dc4cc2daa33b119 Mon Sep 17 00:00:00 2001 From: Faruq Rasid Date: Sat, 29 Oct 2022 22:42:45 +0800 Subject: [PATCH 2/2] Fix issue caused by viewabilityConfig hack --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index acb07fd..c1af123 100755 --- a/src/index.js +++ b/src/index.js @@ -20,7 +20,7 @@ import NextButton from './buttons/NextButton'; import DoneButton from './buttons/DoneButton'; // hotfix: https://github.com/facebook/react-native/issues/16710 -const itemVisibleHotfix = { itemVisiblePercentThreshold: 100 }; +const itemVisibleHotfix = { itemVisiblePercentThreshold: 99 }; class Onboarding extends Component { constructor(props) { @@ -200,7 +200,7 @@ class Onboarding extends Component { onViewableItemsChanged={this.onSwipePageChange} viewabilityConfig={itemVisibleHotfix} initialNumToRender={1} - getItemLayout={(data, index) => ( + getItemLayout={(_data, index) => ( {length: windowWidth, offset: windowWidth * index, index} )} extraData={