Skip to content

Commit

Permalink
ios crashing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmush committed Aug 31, 2020
1 parent 21e226b commit f341e8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"react-native",
"ios"
],
"version": "1.0.0",
"version": "1.0.1",
"description": "Swiper component for React Native.",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 11 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ export default class extends Component {
// related to https://github.com/mdmush/rn-swiper/issues/570
// contentOffset is not working in react 0.48.x so we need to use scrollTo
// to emulate offset.
if (Platform.OS === 'ios') {
if (this.initialRender && this.state.total > 1) {
this.scrollView.scrollTo({...offset, animated: false})
this.initialRender = false;
}
}
// if (Platform.OS === 'ios') {
// if (this.initialRender && this.state.total > 1) {
// this.scrollView.scrollTo({...offset, animated: false})
// this.initialRender = false;
// }
// }

this.setState(state)
}
Expand Down Expand Up @@ -463,11 +463,11 @@ export default class extends Component {
if (state.dir === 'x') x = diff * state.width
if (state.dir === 'y') y = diff * state.height

if (Platform.OS !== 'ios') {
// if (Platform.OS !== 'ios') {
this.scrollView && this.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff)
} else {
this.scrollView && this.scrollView.scrollTo({ x, y, animated })
}
// } else {
// this.scrollView && this.scrollView.scrollTo({ x, y, animated })
// }

// update scroll state
this.internals.isScrolling = true
Expand All @@ -476,7 +476,7 @@ export default class extends Component {
})

// trigger onScrollEnd manually in android
if (!animated || Platform.OS !== 'ios') {
if (!animated) {
setImmediate(() => {
this.onScrollEnd({
nativeEvent: {
Expand Down

0 comments on commit f341e8a

Please sign in to comment.