File tree Expand file tree Collapse file tree 3 files changed +37
-5
lines changed
Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,23 @@ export class PagerView extends React.Component<NativeProps> {
151151 ref = { ( ref ) => {
152152 this . pagerView = ref ;
153153 } }
154- style = { this . props . style }
154+ style = { [
155+ this . props . style ,
156+ Platform . OS === 'ios' && this . props . pageMargin
157+ ? {
158+ marginHorizontal : - this . props . pageMargin / 2 ,
159+ }
160+ : null ,
161+ ] }
155162 layoutDirection = { this . deducedLayoutDirection }
156163 onPageScroll = { this . _onPageScroll }
157164 onPageScrollStateChanged = { this . _onPageScrollStateChanged }
158165 onPageSelected = { this . _onPageSelected }
159166 onMoveShouldSetResponderCapture = { this . _onMoveShouldSetResponderCapture }
160- children = { childrenWithOverriddenStyle ( this . props . children ) }
167+ children = { childrenWithOverriddenStyle (
168+ this . props . children ,
169+ this . props . pageMargin
170+ ) }
161171 />
162172 ) ;
163173 }
Original file line number Diff line number Diff line change 1+ import React , { Children , ReactNode } from 'react' ;
2+ import { StyleSheet , View } from 'react-native' ;
3+
4+ export const childrenWithOverriddenStyle = (
5+ children ?: ReactNode ,
6+ pageMargin = 0
7+ ) => {
8+ return Children . map ( children , ( child ) => {
9+ return (
10+ < View
11+ style = { [
12+ StyleSheet . absoluteFill ,
13+ { marginRight : pageMargin / 2 , marginLeft : pageMargin / 2 } ,
14+ ] }
15+ collapsable = { false }
16+ >
17+ { child }
18+ </ View >
19+ ) ;
20+ } ) ;
21+ } ;
Original file line number Diff line number Diff line change 11import React , { Children , ReactNode } from 'react' ;
22import { StyleSheet , View } from 'react-native' ;
33
4- export const childrenWithOverriddenStyle = ( children ?: ReactNode ) => {
4+ export const childrenWithOverriddenStyle = (
5+ children ?: ReactNode ,
6+ _pageMargin = 0
7+ ) => {
58 return Children . map ( children , ( child ) => {
69 const element = child as React . ReactElement < any > ;
710 return (
8- // Add a wrapper to ensure layout is calculated correctly
911 < View style = { StyleSheet . absoluteFill } collapsable = { false } >
1012 { React . cloneElement ( element , {
1113 ...element . props ,
12- // Override styles so that each page will fill the parent.
1314 style : [ element . props . style , StyleSheet . absoluteFill ] ,
1415 } ) }
1516 </ View >
You can’t perform that action at this time.
0 commit comments