Skip to content

Commit dbf49b5

Browse files
Inbal-Tishethanshar
authored andcommitted
fix for orientation (#501)
1 parent fa6b6e2 commit dbf49b5

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

demo/src/screens/componentScreens/ActionBarScreen.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export default class ActionBarScreen extends Component {
1313

1414
constructor(props) {
1515
super(props);
16-
this.state = {currentPage: 0};
16+
17+
this.state = {
18+
currentPage: 0
19+
};
1720
}
1821

1922
render() {
@@ -36,7 +39,7 @@ export default class ActionBarScreen extends Component {
3639
actions={[
3740
{label: 'Delete', onPress: () => Alert.alert('delete'), red30: true},
3841
{label: 'Replace Photo', onPress: () => Alert.alert('replace photo')},
39-
{label: 'Edit', onPress: () => Alert.alert('edit')},
42+
{label: 'Edit', onPress: () => Alert.alert('edit')}
4043
]}
4144
/>
4245
</View>
@@ -47,7 +50,7 @@ export default class ActionBarScreen extends Component {
4750
actions={[
4851
{label: 'Hide', onPress: () => Alert.alert('hide'), white: true},
4952
{label: 'Add Discount', onPress: () => Alert.alert('add discount'), white: true},
50-
{label: 'Duplicate', onPress: () => Alert.alert('duplicate'), white: true},
53+
{label: 'Duplicate', onPress: () => Alert.alert('duplicate'), white: true}
5154
]}
5255
/>
5356
</View>
@@ -71,7 +74,7 @@ export default class ActionBarScreen extends Component {
7174
actions={[
7275
{label: 'Bold', labelStyle: {color: Colors.dark10, ...Typography.text60, fontWeight: '400'}},
7376
{label: 'Italic', text60: true, labelStyle: {fontStyle: 'italic', color: Colors.dark10}},
74-
{label: 'Link', text60: true, labelStyle: {textDecorationLine: 'underline', color: Colors.dark10}},
77+
{label: 'Link', text60: true, labelStyle: {textDecorationLine: 'underline', color: Colors.dark10}}
7578
]}
7679
/>
7780
</View>
@@ -98,8 +101,8 @@ const styles = StyleSheet.create({
98101
},
99102
absoluteContainer: {
100103
position: 'absolute',
101-
bottom: 70,
104+
bottom: 80,
102105
left: 0,
103-
right: 0,
104-
},
106+
right: 0
107+
}
105108
});

src/components/carousel/CarouselPresenter-Deprecated.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function getDirectionOffset(offset, props) {
66
let fixedOffset = offset;
77

88
if (Constants.isRTL && Constants.isAndroid) {
9-
const {loop, pageWidth} = props;
9+
const {loop, pageWidth = Constants.screenWidth} = props;
1010
const totalWidth = ((getChildrenLength(props) - 1) + (loop ? 2 : 0)) * pageWidth;
1111
fixedOffset = Math.abs(totalWidth - offset);
1212
}
@@ -21,7 +21,7 @@ export function getChildrenLength(props) {
2121

2222
export function calcOffset(props, state) {
2323
const {currentPage} = state;
24-
const {pageWidth, loop} = props;
24+
const {pageWidth = Constants.screenWidth, loop} = props;
2525

2626
const actualCurrentPage = loop ? currentPage + 1 : currentPage;
2727

@@ -33,7 +33,7 @@ export function calcOffset(props, state) {
3333

3434
export function calcPageIndex(offset, props) {
3535
const pagesCount = getChildrenLength(props);
36-
const {pageWidth, loop} = props;
36+
const {pageWidth = Constants.screenWidth, loop} = props;
3737
const pageIndexIncludingClonedPages = Math.round(offset / pageWidth);
3838

3939
let actualPageIndex;
@@ -47,7 +47,7 @@ export function calcPageIndex(offset, props) {
4747
}
4848

4949
export function isOutOfBounds(offset, props) {
50-
const {pageWidth} = props;
50+
const {pageWidth = Constants.screenWidth} = props;
5151
const length = getChildrenLength(props);
5252
const minLimit = 1;
5353
const maxLimit = ((length + 1) * pageWidth) - 1;
@@ -57,7 +57,7 @@ export function isOutOfBounds(offset, props) {
5757

5858
// todo: need to support more cases of page width in loop mode
5959
export function calcCarouselWidth(props) {
60-
const {pageWidth, loop} = props;
60+
const {pageWidth = Constants.screenWidth, loop} = props;
6161
let length = getChildrenLength(props);
6262
length = loop ? length + 2 : length;
6363
return pageWidth * length;

src/components/carousel/carousel-Deprecated.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ export default class CarouselDeprecated extends BaseComponent {
4747
};
4848

4949
static defaultProps = {
50-
initialPage: 0,
51-
pageWidth: Constants.screenWidth
50+
initialPage: 0
5251
};
5352

5453
constructor(props) {
@@ -67,10 +66,6 @@ export default class CarouselDeprecated extends BaseComponent {
6766
this.styles = createStyles(this.props);
6867
}
6968

70-
get pageWidth() {
71-
return Math.floor(this.props.pageWidth);
72-
}
73-
7469
updateOffset = (animated = false) => {
7570
const x = presenter.calcOffset(this.props, this.state);
7671

0 commit comments

Comments
 (0)