Skip to content

Commit 5ec6524

Browse files
committed
Fix bounces on IOS
1 parent a127524 commit 5ec6524

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2-
import {Modal, Dimensions, VirtualizedList, View} from 'react-native';
2+
import {Modal, Dimensions, VirtualizedList, Platform} from 'react-native';
33
import Image from './Image';
4-
import {ImageViewerImageProps, ImageViewerComponentProps, ImageViewerComponentState, SwipeDirection} from './types';
4+
import {ImageViewerImageProps, ImageViewerComponentProps, ImageViewerComponentState} from './types';
55

66
const SCREEN_WIDTH = Dimensions.get('window').width;
77

@@ -47,6 +47,14 @@ class ImageViewer extends React.Component<ImageViewerComponentProps, ImageViewer
4747
private _keyExtractor = (_item: ImageViewerImageProps, index: number) => `${index}`;
4848

4949
render() {
50+
const platformProps = Platform.select({
51+
ios: {
52+
bounces: false,
53+
directionalLockEnabled: true,
54+
},
55+
android: {},
56+
});
57+
5058
return (
5159
<Modal visible={this.props.visible} transparent animationType={this.props.animationType} onRequestClose={this._closeInternal}>
5260
<VirtualizedList
@@ -64,10 +72,12 @@ class ImageViewer extends React.Component<ImageViewerComponentProps, ImageViewer
6472
removeClippedSubviews={true}
6573
maxToRenderPerBatch={2}
6674
initialNumToRender={2}
75+
updateCellsBatchingPeriod={100}
6776
pagingEnabled
68-
initialScrollIndex={this.props.initialIndex !== undefined ? this.props.initialIndex : 0}
77+
initialScrollIndex={this.props.initialIndex}
6978
listKey={'RNImageViewer'}
7079
disableScrollViewPanResponder={!this.state.scrollEnabled}
80+
{...platformProps}
7181
/>
7282
</Modal>
7383
);

0 commit comments

Comments
 (0)