diff --git a/src/PagerView.tsx b/src/PagerView.tsx index 5bb6401c..e923d21f 100644 --- a/src/PagerView.tsx +++ b/src/PagerView.tsx @@ -154,9 +154,9 @@ export class PagerView extends React.Component { style={[ this.props.style, Platform.OS === 'ios' && this.props.pageMargin - ? { - marginHorizontal: -this.props.pageMargin / 2, - } + ? this.props.orientation === 'vertical' + ? { marginVertical: -this.props.pageMargin / 2 } + : { marginHorizontal: -this.props.pageMargin / 2 } : null, ]} layoutDirection={this.deducedLayoutDirection} @@ -166,7 +166,8 @@ export class PagerView extends React.Component { onMoveShouldSetResponderCapture={this._onMoveShouldSetResponderCapture} children={childrenWithOverriddenStyle( this.props.children, - this.props.pageMargin + this.props.pageMargin, + this.props.orientation ?? 'horizontal' )} /> ); diff --git a/src/utils.ios.tsx b/src/utils.ios.tsx index 7bb5a339..d764e1a5 100644 --- a/src/utils.ios.tsx +++ b/src/utils.ios.tsx @@ -3,7 +3,8 @@ import { StyleSheet, View } from 'react-native'; export const childrenWithOverriddenStyle = ( children?: ReactNode, - pageMargin = 0 + pageMargin = 0, + orientation: 'horizontal' | 'vertical' = 'horizontal' ) => { return Children.map(children, (child) => { const element = child as React.ReactElement; @@ -11,7 +12,9 @@ export const childrenWithOverriddenStyle = ( diff --git a/src/utils.tsx b/src/utils.tsx index bf2367a5..fcefe73b 100644 --- a/src/utils.tsx +++ b/src/utils.tsx @@ -3,7 +3,8 @@ import { StyleSheet, View } from 'react-native'; export const childrenWithOverriddenStyle = ( children?: ReactNode, - _pageMargin = 0 + _pageMargin = 0, + _orientation: 'horizontal' | 'vertical' = 'horizontal' ) => { return Children.map(children, (child) => { const element = child as React.ReactElement;